function writeDebug() { if (isDev() && isInternal()) { echo "<div id='debug'>\n\t<h5>Debug Output</h5>\n"; foreach ($GLOBALS['aDebug'] as $d) { echo "\t\t<p>{$d}</p>\n"; } echo "\t<h5>SESSION</h5>\n"; foreach ($_SESSION as $k => $v) { echo "\t\t<p>{$k}: {$v}</p>\n"; } echo "\t<h5>POST: Cleaned</h5>\n"; foreach ($GLOBALS['aPost'] as $k => $v) { echo "\t\t<p>{$k}: {$v}</p>\n"; } echo "\t<h5>POST: Raw</h5>\n"; foreach ($_POST as $k => $v) { echo "\t\t<p>{$k}: {$v}</p>\n"; } echo "\t<h5>GET (Query String)</h5>\n"; foreach ($_GET as $k => $v) { echo "\t\t<p>{$k}: {$v}</p>\n"; } echo "\t<h5>FILES</h5>\n"; print_r($_FILES); echo "\t<h5>DEBUG</h5>\n"; foreach ($_SERVER as $k => $v) { echo "\t\t<p>{$k}: {$v}</p>\n"; } echo "</div>\n"; } }
function onAfterRender() { $isDebug=false; $css=$this->param('css'); $javascript=$this->param('javascript'); if(!$css&&!$javascript){ return true; } // Only render for the front site $app =& JFactory::getApplication(); if($app->getName() != 'site') { return true; } $document =& JFactory::getDocument(); $doctype = $document->getType(); // Only render for HTML output if ( $doctype != 'html' ) { return; } //excludeComponents $excludeComponents=$this->param('excludeComponents'); if(isset($excludeComponents)&&$excludeComponents){ $components=@explode(',',$excludeComponents); $option=JRequest::getVar('option'); if(isset($option)&&in_array($option,$components)){ return true; } } //gzip checking $isGZ=$this->param('gzip'); if($isGZ){ $encoding = JResponse::_clientEncoding(); if (!$encoding){ $isGZ=false; } if (!extension_loaded('zlib') || ini_get('zlib.output_compression')) { $isGZ=false; } } $body = JResponse::getBody(); $isok=true; $compressor=new jsCssCompressor(); $baseUrl=JURI::base(true).'/'; if($javascript){ $scriptRegex="/<script [^>]+(\/>|><\/script>)/i"; $jsRegex="/([^\"\'=]+\.(js))[\"\']/i"; preg_match_all($scriptRegex, $body, $matches); $scripts=@implode('',$matches[0]); preg_match_all($jsRegex,$scripts,$matches); $scriptFiles= array(); foreach($matches[1] as $script){ if(isInternal($script)){ //if $baseurl=='/'; may need specail handle $parts=@explode( JURI::base(),$script); if(count($parts)>1&&endwith($parts[1],'.js')){ $script=JPATH_ROOT.DS.$parts[1]; $script=replaceSperator($script); $scriptFiles[]=$script; }else if(endwith($script,'.js')){ $script=$_SERVER['DOCUMENT_ROOT'].DS.$script; $script=replaceSperator($script); if(file_exists($script)){ $scriptFiles[]=$script; }else{ $script=JPATH_ROOT.DS.$script; $script=replaceSperator($script); if(file_exists($script)){ $scriptFiles[]=$script; } } } } } $scriptFiles=array_unique($scriptFiles); $customOrder=$this->param('customOrder'); $jqueryNoConflict=$this->param('jqueryNoConflict'); $jquery=$this->param('jquery'); $exclude=$this->param('excludeJs'); $excludeJs=array(); if(isset($exclude)&&$exclude){ $excludeJs=@explode(',',$exclude); } $predefinedExcludeJs=array('xajax.js','script.js','tiny_mce.js','com_community/assets/toolbar.js'); $excludeJs=@array_merge($excludeJs,$predefinedExcludeJs); $mappedScripts=array(); foreach($scriptFiles as $sf){ $file=strrchr($sf,DS); if(isset($file)){ $file=substr($file,1); $mappedScripts[trim($file)]=$sf; } } $firstScripts=explode(',',$customOrder); $orderedScripts=array(); foreach($firstScripts as $fs){ $fs=trim($fs); if(array_key_exists($fs,$mappedScripts)){ $orderedScripts[]=$mappedScripts[$fs]; } } //append all js, ignore customorded files foreach($scriptFiles as $sf){ if(!in_array($sf,$orderedScripts)){ $orderedScripts[]=$sf; } } if(isset($jquery)&&isset($mappedScripts[$jquery])){