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


PHP Less_Environment::NormPath方法代码示例

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


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

示例1: datauri

	function datauri($mimetypeNode, $filePathNode = null ) {

		$filePath = ( $filePathNode ? $filePathNode->value : null );
		$mimetype = $mimetypeNode->value;
		$useBase64 = false;

		$args = 2;
		if( !$filePath ){
			$filePath = $mimetype;
			$args = 1;
		}

		$filePath = str_replace('\\','/',$filePath);
		if( Less_Environment::isPathRelative($filePath) ){

			if( $this->relativeUrls ){
				$temp = $this->currentFileInfo['currentDirectory'];
			} else {
				$temp = $this->currentFileInfo['entryPath'];
			}

			if( !empty($temp) ){
				$filePath = Less_Environment::NormPath(rtrim($temp,'/').'/'.$filePath);
			}

		}


		// detect the mimetype if not given
		if( $args < 2 ){

			/* incomplete
			$mime = require('mime');
			mimetype = mime.lookup(path);

			// use base 64 unless it's an ASCII or UTF-8 format
			var charset = mime.charsets.lookup(mimetype);
			useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0;
			if (useBase64) mimetype += ';base64';
			*/

			$mimetype = Less_Mime::lookup($filePath);

			$charset = Less_Mime::charsets_lookup($mimetype);
			$useBase64 = !in_array($charset,array('US-ASCII', 'UTF-8'));
			if ($useBase64) $mimetype .= ';base64';

		}else{
			$useBase64 = preg_match('/;base64$/',$mimetype);
		}


		if( file_exists($filePath) ){
			$buf = @file_get_contents($filePath);
		}else{
			$buf = false;
		}


		// IE8 cannot handle a data-uri larger than 32KB. If this is exceeded
		// and the --ieCompat flag is enabled, return a normal url() instead.
		$DATA_URI_MAX_KB = 32;
		$fileSizeInKB = round( strlen($buf) / 1024 );
		if( $fileSizeInKB >= $DATA_URI_MAX_KB ){
			$url = new Less_Tree_Url( ($filePathNode ? $filePathNode : $mimetypeNode), $this->currentFileInfo);
			return $url->compile($this);
		}

		if( $buf ){
			$buf = $useBase64 ? base64_encode($buf) : rawurlencode($buf);
			$filePath = "'data:" . $mimetype . ',' . $buf . "'";
		}

		return new Less_Tree_Url( new Less_Tree_Anonymous($filePath) );
	}
开发者ID:nicomollet,项目名称:stormbringer,代码行数:75,代码来源:Environment.php

示例2: compile

 function compile($env)
 {
     $evald = $this->compileForImport($env);
     $uri = $full_path = false;
     //get path & uri
     $evald_path = $evald->getPath();
     if ($evald_path && $env->isPathRelative($evald_path)) {
         foreach (Less_Parser::$import_dirs as $rootpath => $rooturi) {
             $temp = $rootpath . $evald_path;
             if (file_exists($temp)) {
                 $full_path = Less_Environment::NormPath($temp);
                 $uri = Less_Environment::NormPath(dirname($rooturi . $evald_path));
                 break;
             }
         }
     }
     if (!$full_path) {
         $uri = $evald_path;
         $full_path = $evald_path;
     }
     //import once
     $realpath = realpath($full_path);
     if (!isset($evald->options['multiple']) && $realpath && Less_Parser::FileParsed($realpath)) {
         $evald->skip = true;
     }
     $features = $evald->features ? $evald->features->compile($env) : null;
     if ($evald->skip) {
         return array();
     }
     if ($evald->css) {
         $temp = $this->compilePath($env);
         return new Less_Tree_Import($this->compilePath($env), $features, $this->options, $this->index);
     }
     $parser = new Less_Parser($env);
     $evald->root = $parser->parseFile($full_path, $uri, true);
     $ruleset = new Less_Tree_Ruleset(array(), $evald->root->rules);
     $ruleset->evalImports($env);
     return $this->features ? new Less_Tree_Media($ruleset->rules, $this->features->value) : $ruleset->rules;
 }
开发者ID:satokora,项目名称:IT354Project,代码行数:39,代码来源:Import.php

示例3: SetFileInfo

	public function SetFileInfo( $filename, $uri_root = ''){

		$this->path = pathinfo($filename, PATHINFO_DIRNAME);
		$this->filename = Less_Environment::NormPath($filename);

		$dirname = preg_replace('/[^\/\\\\]*$/','',$this->filename);

		$currentFileInfo = array();
		$currentFileInfo['currentDirectory'] = $dirname;
		$currentFileInfo['filename'] = $filename;
		$currentFileInfo['rootpath'] = $dirname;
		$currentFileInfo['entryPath'] = $dirname;

		if( empty($uri_root) ){
			$currentFileInfo['uri_root'] = $uri_root;
		}else{
			$currentFileInfo['uri_root'] = rtrim($uri_root,'/').'/';
		}

		$this->env->currentFileInfo = $currentFileInfo;

		self::$import_dirs = array_merge( array( $dirname => $currentFileInfo['uri_root'] ), self::$import_dirs );
	}
开发者ID:nicomollet,项目名称:stormbringer,代码行数:23,代码来源:Parser.php


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