コード例 #1
0
ファイル: yt.php プロジェクト: johngrange/wookeyholeweb
 function onAfterRender()
 {
     global $app;
     //var_dump($app); die();
     $document = JFactory::getDocument();
     $option = JRequest::getVar('option', '');
     $task = JRequest::getVar('task', '');
     if ($app->isSite() && $document->_type == 'html' && !$app->getCfg('offline') && !($option == 'com_content' && $task == 'edit')) {
         require_once 'includes/libs/yt-minify.php';
         $yt_mini = new YT_Minify();
         if ($app->getTemplate(true)->params->get('optimizeCSS', 0)) {
             $yt_mini->optimizecss();
         }
         if ($app->getTemplate(true)->params->get('optimizeJS', 0)) {
             $yt_mini->optimizejs();
         }
         if ($app->getTemplate(true)->params->get('optimizeHTML', 0)) {
             $yt_mini->optimizehtml();
         }
         $type = JRequest::getVar('type');
         $action = JRequest::getVar('action');
         if ($type == 'plugin' && $action == 'clearCache') {
             $yt_mini->clearCache();
         }
     } else {
         $uri = str_replace(JPATH_SITE, JURI::base(), dirname(__FILE__));
         $uri = str_replace(DIRECTORY_SEPARATOR, '/', str_replace("/administrator/", "", $uri));
         //die($uri);
         $html = "";
         $html = '<script language="javascript" type="text/javascript" src="' . $uri . '/includes/assets/clearcache.js"></script>';
         if ($this->params->get('show_sjhelp', 0) == 1) {
             require_once 'includes/assets/menu-sjhelp.php';
         }
         $buffer = JResponse::getBody();
         $buffer = preg_replace('/<\\/head>/', $html . "\n</head>", $buffer);
         JResponse::setBody($buffer);
     }
 }
コード例 #2
0
ファイル: yt.php プロジェクト: rodhoff/MNW
 function onAfterRender()
 {
     global $app;
     $document = JFactory::getDocument();
     $option = JRequest::getVar('option', '');
     $task = JRequest::getVar('task', '');
     $this->snippet();
     //  Minify
     if ($app->isSite() && $document->_type == 'html' && !$app->getCfg('offline') && !($option == 'com_content' && $task == 'edit')) {
         require_once YT_INCLUDES_PATH . J_SEPARATOR . 'libs' . J_SEPARATOR . 'yt-minify.php';
         $yt_mini = new YT_Minify();
         if ($app->getTemplate(true)->params->get('optimizeCSS', 0)) {
             $yt_mini->optimizecss();
         }
         if ($app->getTemplate(true)->params->get('optimizeJS', 0)) {
             $yt_mini->optimizejs();
         }
         if (JRequest::getVar('type') == 'plugin' && JRequest::getVar('action') == 'clearCache') {
             $yt_mini->clearCache();
         }
     }
     if ($this->nameOfSJTemplate()) {
         // Override template backend. New UI
         if ($app->isAdmin()) {
             $body = JResponse::getBody();
             if (JRequest::getCmd('view') == 'style') {
                 // Template Content
                 ob_start();
                 require_once YT_INCLUDES_PATH . '/admin/template/default.php';
                 $buffer = ob_get_clean();
                 $body1 = preg_replace('@<form\\s[^>]*name="adminForm"[^>]*>?.*?</form>@siu', $buffer, $body);
                 if (preg_last_error() == PREG_BACKTRACK_LIMIT_ERROR) {
                     ini_set('pcre.backtrack_limit', (int) ini_get('pcre.backtrack_limit') + 15000);
                     $body1 = preg_replace('@<form\\s[^>]*name="adminForm"[^>]*>([\\w|\\W]*)</form>@msu', $buffer, $body);
                 }
                 if ($body1 != null) {
                     JResponse::setBody($body1);
                 } else {
                     die('Error occurred because preg_replace is null');
                 }
             }
         }
     }
     // Site offline
     if ($app->getCfg('offline')) {
         if (!class_exists('YT_Minify')) {
             require_once YT_INCLUDES_PATH . J_SEPARATOR . 'libs' . J_SEPARATOR . 'yt-minify.php';
         }
     }
 }