public static function writeToFile($to_file, $data, $type, $overrideGZ = false) { if (!$to_file) { return false; } $to_file = JBETOLO_CACHE_DIR . '/' . str_replace(JBETOLO_CACHE_DIR . '/', '', $to_file); if (JFile::exists($to_file)) { return true; } if ($type == 'css' || $type == 'js') { $minify = JBETOLO_IS_MINIFY && plgSystemJBetolo::param($type . '_minify'); $exclMinify = plgSystemJBetolo::param('minify_exclude'); if (is_array($data)) { if ($minify && $exclMinify && count($exclMinify) > 0) { $exclMinify = explode(',', $exclMinify); foreach ($data as $d => $content) { if (jbetoloFileHelper::isFileExcluded($content['file'], $exclMinify)) { $data[$d] = $content['content']; } else { $data[$d] = jbetoloFileHelper::minify($type, $content['content']); } } $data = implode("\n", $data); } else { $data = jbetoloHelper::getArrayValues($data, 'content'); $data = implode("\n", $data); if ($minify) { $data = jbetoloFileHelper::minify($type, $data); } } } else { if ($minify) { $data = jbetoloFileHelper::minify($type, $data); } else { $data = jbetoloHelper::eatWhiteSpace($data); } } } if (JBETOLO_IS_GZ && (plgSystemJBetolo::param($type . '_gzip') || $overrideGZ)) { $data = gzencode($data); JFile::write($to_file, $data); } else { JFile::write($to_file, $data); } return true; }
function onAfterRender() { if (self::dontJbetolo()) { if (!self::dontJbetolo('cdn')) { $body = JResponse::getBody(); if (jbetoloHelper::mapCDN($body)) { JResponse::setBody($body); } } if (self::doJbetolo('jbetolo')) { if (self::param('js_jquery_migrate_plugin', 0)) { $jquery .= '<script type="text/javascript" src="' . JBETOLO_URI_BASE . 'plugins/system/jbetolo/jbetolo/assets/jquery/' . JBETOLO_JQUERY_MIGRATE_PLUGIN . '"></script>'; } if (self::param('add_local_jquery', 0) && self::doJbetolo('add_local_jquery_always')) { $body = JResponse::getBody(); $jquery = '<script type="text/javascript" src="' . JBETOLO_URI_BASE . 'plugins/system/jbetolo/jbetolo/assets/jquery/' . JBETOLO_JQUERY . '"></script>'; if (self::param('add_local_jquery_ui', 0)) { $jquery .= '<script type="text/javascript" src="' . JBETOLO_URI_BASE . 'plugins/system/jbetolo/jbetolo/assets/jquery-ui/js/' . JBETOLO_JQUERY_UI . '"></script>'; } if (self::param('js_jquery_no_conflict')) { $jquery .= "\n <script type='text/javascript'>jQuery.noConflict();</script>\n"; } jbetoloFileHelper::placeTags($body, $jquery, 'js', 2); JResponse::setBody($body); } } return; } else { $body = JResponse::getBody(); } if (JBETOLO_DEBUG) { jbetoloHelper::timer(); jbetoloHelper::resetCache(); } jbetoloHelper::lazyLoad($body, 1); //jbetoloHelper::loadClientsiderErrorLogger($body); //jbetoloHelper::handleChanges(); $_comments = $_conds = $_srcs = $_esrcs = $_tags = $_indexes = array(); if (self::param('cdnjs', false)) { $jss = self::param('cdnjs', false); foreach ($jss as &$js) { $js = '<script type="text/javascript" src="' . $js . '"></script>'; } jbetoloFileHelper::placeTags($body, $jss, 'js'); } list($_srcs['css'], $_esrcs['css'], $_tags['css'], $_conds['css'], $_comments['css'], $_indexes['css']) = $this->parseBody($body, 'css'); list($_srcs['js'], $_esrcs['js'], $_tags['js'], $_conds['js'], $_comments['js'], $_indexes['js']) = $this->parseBody($body, 'js'); jbetoloFileHelper::createFile($body, $_srcs, $_esrcs, $_tags, $_conds, $_comments, $_indexes); jbetoloJS::modifyInlineScripts($body); jbetoloFileHelper::finalizePlaceTags($body); if (self::param('html_minify')) { $body = jbetoloFileHelper::minify('html', $body); } jbetoloHelper::lazyLoad($body, 2); jbetoloHelper::mapCDN($body); if (JBETOLO_DEBUG) { jbetoloHelper::timer(false, true, $body); } JResponse::setBody($body); // jbetoloHelper::sanityCheck(); }