当前位置: 首页>>代码示例>>PHP>>正文


PHP JResponse::_clientEncoding方法代码示例

本文整理汇总了PHP中JResponse::_clientEncoding方法的典型用法代码示例。如果您正苦于以下问题:PHP JResponse::_clientEncoding方法的具体用法?PHP JResponse::_clientEncoding怎么用?PHP JResponse::_clientEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JResponse的用法示例。


在下文中一共展示了JResponse::_clientEncoding方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onAfterRender

	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];
//.........这里部分代码省略.........
开发者ID:xenten,项目名称:swift-kanban,代码行数:101,代码来源:CssJsCompress.php

示例2: sendHeaders

 function sendHeaders()
 {
     // Don't compress something if the server is going todo it anyway. Waste of time.
     $this->doCompression = $this->sitemap->compress_xml && !ini_get('zlib.output_compression') && ini_get('output_handler') != 'ob_gzhandler';
     @ob_end_clean();
     if ($this->doCompression) {
         $encoding = JResponse::_clientEncoding();
         header('Content-Encoding: ' . $encoding);
         header('X-Content-Encoded-By: Joomla! 1.5');
         ob_start();
     }
     header('Content-type: application/xml; charset=utf-8');
 }
开发者ID:sangkasi,项目名称:joomla,代码行数:13,代码来源:xmap.xml.php

示例3: _compress

 /**
  * Compress the data
  *
  * Checks the accept encoding of the browser and compresses the data before
  * sending it to the client.
  *
  * @access	public
  * @param	string		data
  * @return	string		compressed data
  */
 function _compress($data)
 {
     $encoding = JResponse::_clientEncoding();
     if (!$encoding) {
         return $data;
     }
     if (!extension_loaded('zlib') || ini_get('zlib.output_compression')) {
         return $data;
     }
     if (headers_sent()) {
         return $data;
     }
     if (connection_status() !== 0) {
         return $data;
     }
     $level = 4;
     //ideal level
     /*
     $size		= strlen($data);
     $crc		= crc32($data);
     
     $gzdata		= "\x1f\x8b\x08\x00\x00\x00\x00\x00";
     $gzdata		.= gzcompress($data, $level);
     
     $gzdata 	= substr($gzdata, 0, strlen($gzdata) - 4);
     $gzdata 	.= pack("V",$crc) . pack("V", $size);
     */
     $gzdata = gzencode($data, $level);
     JResponse::setHeader('Content-Encoding', $encoding);
     JResponse::setHeader('X-Content-Encoded-By', 'Joomla! 1.5');
     return $gzdata;
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:42,代码来源:response.php

示例4: startOutput

 function startOutput(&$menus, &$config)
 {
     $live_site = substr_replace(JURI::root(), "", -1, 1);
     $this->isNews = JRequest::getInt('news', 0);
     // Don't compress something if the server is going todo it anyway. Waste of time.
     $this->doCompression = $this->sitemap->compress_xml && !ini_get('zlib.output_compression') && ini_get('output_handler') != 'ob_gzhandler';
     @ob_end_clean();
     if ($this->doCompression) {
         $encoding = JResponse::_clientEncoding();
         header('Content-Encoding: ' . $encoding);
         header('X-Content-Encoded-By: Joomla! 1.5');
         ob_start();
     }
     header('Content-type: application/xml; charset=utf-8');
     echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     if (!$config->exclude_xsl && !$this->isNews) {
         $user =& JFactory::getUser();
         if ($user->get('gid') == "25") {
             echo '<?xml-stylesheet type="text/xsl" href="' . $live_site . '/index2.php?option=com_xmap&amp;view=xsladminfile&amp;tmpl=component"?>' . "\n";
         } else {
             echo '<?xml-stylesheet type="text/xsl" href="' . $live_site . '/index2.php?option=com_xmap&amp;view=xslfile&amp;tmpl=component"?>' . "\n";
         }
     }
     echo '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 ' . 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" ' . 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" ' . 'xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"' . ($this->isNews ? ' xmlns:n="http://www.google.com/schemas/sitemap-news/0.9"' : '') . ">\n";
 }
开发者ID:omarmm,项目名称:MangLuoiBDS,代码行数:25,代码来源:xmap.xml.php


注:本文中的JResponse::_clientEncoding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。