/**
  * 
  * @return boolean
  * @throws Exception
  */
 public function onAfterRender()
 {
     $app = JFactory::getApplication();
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     if ($app->getName() != 'site' || JFactory::getDocument()->getType() != 'html' || $app->input->get('jchbackend', '', 'int') == 1 || $config->get('offline') && $user->guest || $this->isEditorLoaded()) {
         return FALSE;
     }
     if ($this->params->get('log', 0)) {
         error_reporting(E_ALL & ~E_NOTICE);
     }
     $sHtml = $app->getBody();
     if ($app->input->get('jchbackend') == '2') {
         echo $sHtml;
         while (@ob_end_flush()) {
         }
         exit;
     }
     if (!defined('JCH_VERSION')) {
         define('JCH_VERSION', '5.0.5');
     }
     try {
         loadJchOptimizeClass('JchOptimize');
         $sOptimizedHtml = JchOptimize::optimize($this->params, $sHtml);
     } catch (Exception $ex) {
         JchOptimizeLogger::log($ex->getMessage(), JchPlatformSettings::getInstance($this->params));
         $sOptimizedHtml = $sHtml;
     }
     $app->setBody($sOptimizedHtml);
 }
Esempio n. 2
0
 /**
  * Constructor
  * 
  * @param type $oParams  Plugin parameters
  */
 private function __construct($oParams)
 {
     loadJchOptimizeClass('JchPlatformSettings');
     ini_set('pcre.backtrack_limit', 1000000);
     ini_set('pcre.recursion_limit', 100000);
     $this->params = JchPlatformSettings::getInstance($oParams);
 }
Esempio n. 3
0
 /**
  * Constructor
  * 
  * @param type $oParams  Plugin parameters
  */
 private function __construct($oParams)
 {
     loadJchOptimizeClass('JchPlatformSettings');
     ini_set('pcre.backtrack_limit', 1000000);
     $this->params = JchPlatformSettings::getInstance($oParams);
     if (!defined('JCH_VERSION')) {
         define('JCH_VERSION', '4.2.0');
     }
 }
Esempio n. 4
0
function loadJchOptimizeClass($sClass)
{
    //        global $_PROFILER;
    //        JDEBUG ? $_PROFILER->mark('beforeLoadClass - ' . $sClass . ' (JCH Optimize)') : null;
    if (is_array($sClass)) {
        foreach ($sClass as $class) {
            loadJchOptimizeClass($class);
        }
    } else {
        $class = $sClass;
    }
    $prefix = substr($class, 0, 3);
    // If the class already exists do nothing.
    if (class_exists($class, false)) {
        return true;
    }
    if ($prefix !== 'Jch') {
        return false;
    } else {
        $class = str_replace($prefix, '', $class);
    }
    if (strpos($class, '\\') !== FALSE) {
        $filename = str_replace('Optimize\\', '', $class);
        $file = dirname(__FILE__) . '/libs/' . $filename . '.php';
    } elseif (strpos($class, 'Platform') === 0) {
        $class = str_replace('Platform', '', $class);
        $filename = strtolower($class);
        $file = dirname(dirname(__FILE__)) . '/platform/' . $filename . '.php';
        loadJchOptimizeClass('JchInterface' . $class);
    } elseif (strpos($class, 'Interface') === 0) {
        $filename = strtolower(str_replace('Interface', '', $class));
        $file = dirname(__FILE__) . '/interfaces/' . $filename . '.php';
    } else {
        $filename = str_replace('Optimize', '', $class);
        $filename = strtolower($class == 'Optimize' ? 'jchoptimize' : $filename);
        $file = dirname(__FILE__) . '/' . $filename . '.php';
    }
    if (!file_exists($file)) {
        throw new Exception(sprintf('File not found: %s', $file));
    } else {
        include $file;
        if (!class_exists($sClass) && !interface_exists($sClass)) {
            throw new Exception(sprintf('Class not found: %s', $sClass));
        }
    }
    //        JDEBUG ? $_PROFILER->mark('afterLoadClass - ' . $sClass . ' (JCH Optimize)') : null;
}
Esempio n. 5
0
function loadJchOptimizeClass($sClass)
{
    if (is_array($sClass)) {
        foreach ($sClass as $class) {
            loadJchOptimizeClass($class);
        }
    } else {
        $class = $sClass;
    }
    $prefix = substr($class, 0, 3);
    // If the class already exists do nothing.
    if (class_exists($class, false)) {
        return true;
    }
    if ($prefix !== 'Jch') {
        return false;
    } else {
        $class = str_replace($prefix, '', $class);
    }
    if (strpos($class, '\\') !== FALSE) {
        $filename = str_replace('Optimize\\', '', $class);
        $file = dirname(__FILE__) . '/libs/' . $filename . '.php';
    } elseif (strpos($class, 'Platform') === 0) {
        $class = str_replace('Platform', '', $class);
        $filename = strtolower($class);
        $file = dirname(dirname(__FILE__)) . '/platform/' . $filename . '.php';
        loadJchOptimizeClass('JchInterface' . $class);
    } elseif (strpos($class, 'Interface') === 0) {
        $filename = strtolower(str_replace('Interface', '', $class));
        $file = dirname(__FILE__) . '/interfaces/' . $filename . '.php';
    } else {
        $filename = str_replace('Optimize', '', $class);
        $filename = strtolower($class == 'Optimize' ? 'jchoptimize' : $filename);
        $file = dirname(__FILE__) . '/' . $filename . '.php';
    }
    if (!file_exists($file)) {
        return false;
    } else {
        include $file;
        if (!class_exists($sClass) && !interface_exists($sClass)) {
            return false;
        }
    }
}
Esempio n. 6
0
 /**
  * 
  * @return boolean
  * @throws Exception
  */
 public function onAfterRender()
 {
     if (JDEBUG && $this->params->get('debug', 0)) {
         global $_PROFILER;
         $_PROFILER->mark('beforeOnAfterRender plgSystem (JCH Optimize)');
     }
     $app = JFactory::getApplication();
     $config = JFactory::getConfig();
     $user = JFactory::getUser();
     if ($app->getName() != 'site' || JFactory::getDocument()->getType() != 'html' || $app->input->get('jchbackend', '', 'int') == 1 || $config->get('offline') && $user->guest || class_exists('JEditor', FALSE)) {
         return FALSE;
     }
     if ($this->params->get('log', 0)) {
         error_reporting(E_ALL & ~E_NOTICE);
     }
     if (version_compare(JVERSION, '3.2.3', '>=')) {
         $sHtml = $app->getBody();
     } else {
         $sHtml = JResponse::getBody();
     }
     if ($app->input->get('jchbackend') == '2') {
         echo $sHtml;
         while (@ob_end_flush()) {
         }
         exit;
     }
     try {
         loadJchOptimizeClass('JchOptimize');
         $sOptimizedHtml = JchOptimize::optimize($this->params, $sHtml);
     } catch (Exception $ex) {
         JchOptimizeLogger::log($ex->getMessage(), JchPlatformSettings::getInstance($this->params));
         $sOptimizedHtml = $sHtml;
     }
     if (version_compare(JVERSION, '3.2.3', '>=')) {
         $app->setBody($sOptimizedHtml);
     } else {
         JResponse::setBody($sOptimizedHtml);
     }
     if (JDEBUG && $this->params->get('debug', 0)) {
         $_PROFILER->mark('afterOnAfterRender plgSystem (JCH Optimize)');
     }
 }
 /**
  * Constructor
  * 
  * @param type $oParams  Plugin parameters
  */
 private function __construct($oParams)
 {
     loadJchOptimizeClass('JchPlatformSettings');
     ini_set('pcre.backtrack_limit', 1000000);
     ini_set('pcre.recursion_limit', 100000);
     if (version_compare(PHP_VERSION, '7', '>=')) {
         $this->jit = ini_get('pcre.jit');
         ini_set('pcre.jit', 0);
     }
     $this->params = JchPlatformSettings::getInstance($oParams);
 }
Esempio n. 8
0
 /**
  * Removes applicable js and css links from search area
  * 
  */
 public function parseHtml()
 {
     JCH_DEBUG ? JchPlatformProfiler::start('SetUpExcludes') : null;
     $oParams = $this->params;
     $aCBArgs = array();
     $this->getHeadHtml();
     $this->getBodyHtml();
     if (JchOptimizeHelper::isMsieLT10()) {
         return;
     }
     loadJchOptimizeClass('JchPlatformExcludes');
     $aExJsComp = $this->getExComp($oParams->get('excludeJsComponents', ''));
     $aExCssComp = $this->getExComp($oParams->get('excludeCssComponents', ''));
     $aExcludeJs = JchOptimizeHelper::getArray($oParams->get('excludeJs', ''));
     $aExcludeCss = JchOptimizeHelper::getArray($oParams->get('excludeCss', ''));
     $aExcludeScript = JchOptimizeHelper::getArray($oParams->get('pro_excludeScripts'));
     $aExcludeStyle = JchOptimizeHelper::getArray($oParams->get('pro_excludeStyles'));
     $aExcludeScript = array_map(function ($sScript) {
         return stripslashes($sScript);
     }, $aExcludeScript);
     $aCBArgs['excludes']['js'] = array_merge($aExcludeJs, $aExJsComp, array('.com/maps/api/js', '.com/jsapi', '.com/uds', 'typekit.net'), JchPlatformExcludes::head('js'));
     $aCBArgs['excludes']['css'] = array_merge($aExcludeCss, $aExCssComp, JchPlatformExcludes::head('css'));
     $aCBArgs['excludes']['js_script'] = $aExcludeScript;
     $aCBArgs['excludes']['css_script'] = $aExcludeStyle;
     $aCBArgs['removals']['js'] = JchOptimizeHelper::getArray($oParams->get('removeJs', ''));
     $aCBArgs['removals']['css'] = JchOptimizeHelper::getArray($oParams->get('removeCss', ''));
     JCH_DEBUG ? JchPlatformProfiler::stop('SetUpExcludes', TRUE) : null;
     $this->initSearch($aCBArgs);
     $this->runCookieLessDomain();
     $this->lazyLoadImages();
 }
Esempio n. 9
0
<?php

/**
 * JCH Optimize - Joomla! plugin to aggregate and minify external resources for 
 *   optmized downloads
 * @author Samuel Marshall <*****@*****.**>
 * @copyright Copyright (c) 2010 Samuel Marshall. All rights reserved.
 * @license GNU/GPLv3, See LICENSE file 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * If LICENSE file missing, see <http://www.gnu.org/licenses/>. 
 * 
 * This plugin includes other copyrighted works. See individual 
 * files for details.
 */
//$start = microtime(true);
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/plugins/system/jch_optimize/bootstrap.php';
loadJchOptimizeClass('JchOptimizeOutput');
JchOptimizeOutput::getCombinedFile();
Esempio n. 10
0
 /**
  * Removes applicable js and css links from search area
  * 
  */
 public function parseHtml()
 {
     //                JCH_DEBUG ? JchPlatformProfiler::mark('beforeParseHtml -  plgSystem (JCH Optimize)') : null;
     $oParams = $this->params;
     $aCBArgs = array();
     $this->getHeadHtml();
     $this->getBodyHtml();
     loadJchOptimizeClass('JchPlatformExcludes');
     $aExJsComp = $this->getExComp($oParams->get('excludeJsComponents', ''));
     $aExCssComp = $this->getExComp($oParams->get('excludeCssComponents', ''));
     $aExcludeJs = JchOptimizeHelper::getArray($oParams->get('excludeJs', ''));
     $aExcludeCss = JchOptimizeHelper::getArray($oParams->get('excludeCss', ''));
     $aExcludeScript = JchOptimizeHelper::getArray($oParams->get('pro_excludeScripts'));
     $aExcludeScript = array_map(function ($sScript) {
         return stripslashes($sScript);
     }, $aExcludeScript);
     $aCBArgs['excludes']['js'] = array_merge($aExcludeJs, $aExJsComp, array('.com/maps/api/js', '.com/jsapi', '.com/uds', 'typekit.net'), JchPlatformExcludes::head('js'));
     $aCBArgs['excludes']['css'] = array_merge($aExcludeCss, $aExCssComp, array('fonts.googleapis.com'), JchPlatformExcludes::head('css'));
     $aCBArgs['excludes']['script'] = $aExcludeScript;
     //                JCH_DEBUG ? JchPlatformProfiler::mark('afterParserHtml -  plgSystem (JCH Optimize)') : null;
     $this->initSearch($aCBArgs);
     $this->lazyLoadImages();
     $this->runCookieLessDomain();
 }