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


PHP Less_Environment::isPathRelative方法代码示例

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


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

示例1: compile

 /**
  * @param Less_Functions $ctx
  */
 public function compile($ctx)
 {
     $val = $this->value->compile($ctx);
     if (!$this->isEvald) {
         // Add the base path if the URL is relative
         if (Less_Parser::$options['relativeUrls'] && $this->currentFileInfo && is_string($val->value) && Less_Environment::isPathRelative($val->value)) {
             $rootpath = $this->currentFileInfo['uri_root'];
             if (!$val->quote) {
                 $rootpath = preg_replace('/[\\(\\)\'"\\s]/', '\\$1', $rootpath);
             }
             $val->value = $rootpath . $val->value;
         }
         $val->value = Less_Environment::normalizePath($val->value);
     }
     // Add cache buster if enabled
     if (Less_Parser::$options['urlArgs']) {
         if (!preg_match('/^\\s*data:/', $val->value)) {
             $delimiter = strpos($val->value, '?') === false ? '?' : '&';
             $urlArgs = $delimiter . Less_Parser::$options['urlArgs'];
             $hash_pos = strpos($val->value, '#');
             if ($hash_pos !== false) {
                 $val->value = substr_replace($val->value, $urlArgs, $hash_pos, 0);
             } else {
                 $val->value .= $urlArgs;
             }
         }
     }
     return new Less_Tree_URL($val, $this->currentFileInfo, true);
 }
开发者ID:kevcom,项目名称:scheduler,代码行数:32,代码来源:Url.php

示例2: datauri

 public function datauri($mimetypeNode, $filePathNode = null)
 {
     $filePath = $filePathNode ? $filePathNode->value : null;
     $mimetype = $mimetypeNode->value;
     $args = 2;
     if (!$filePath) {
         $filePath = $mimetype;
         $args = 1;
     }
     $filePath = str_replace('\\', '/', $filePath);
     if (Less_Environment::isPathRelative($filePath)) {
         if (Less_Parser::$options['relativeUrls']) {
             $temp = $this->currentFileInfo['currentDirectory'];
         } else {
             $temp = $this->currentFileInfo['entryPath'];
         }
         if (!empty($temp)) {
             $filePath = Less_Environment::normalizePath(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:renaatdemuynck,项目名称:less.php,代码行数:59,代码来源:Functions.php

示例3: compilePath

 public function compilePath($env)
 {
     $path = $this->path->compile($env);
     $rootpath = '';
     if ($this->currentFileInfo && $this->currentFileInfo['rootpath']) {
         $rootpath = $this->currentFileInfo['rootpath'];
     }
     if (!$path instanceof Less_Tree_URL) {
         if ($rootpath) {
             $pathValue = $path->value;
             // Add the base path if the import is relative
             if ($pathValue && Less_Environment::isPathRelative($pathValue)) {
                 $path->value = $this->currentFileInfo['uri_root'] . $pathValue;
             }
         }
         $path->value = Less_Environment::normalizePath($path->value);
     }
     return $path;
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:19,代码来源:Import.php

示例4: PathAndUri

 /**
  * Using the import directories, get the full absolute path and uri of the import
  *
  * @param Less_Tree_Import $evald
  */
 public function PathAndUri()
 {
     $evald_path = $this->getPath();
     if ($evald_path) {
         $import_dirs = array();
         if (Less_Environment::isPathRelative($evald_path)) {
             //if the path is relative, the file should be in the current directory
             $import_dirs[$this->currentFileInfo['currentDirectory']] = $this->currentFileInfo['uri_root'];
         } else {
             //otherwise, the file should be relative to the server root
             $import_dirs[$this->currentFileInfo['entryPath']] = $this->currentFileInfo['entryUri'];
             //if the user supplied entryPath isn't the actual root
             $import_dirs[$_SERVER['DOCUMENT_ROOT']] = '';
         }
         // always look in user supplied import directories
         $import_dirs = array_merge($import_dirs, Less_Parser::$options['import_dirs']);
         foreach ($import_dirs as $rootpath => $rooturi) {
             if (is_callable($rooturi)) {
                 list($path, $uri) = call_user_func($rooturi, $evald_path);
                 if (is_string($path)) {
                     $full_path = $path;
                     return array($full_path, $uri);
                 }
             } elseif (!empty($rootpath)) {
                 $path = rtrim($rootpath, '/\\') . '/' . ltrim($evald_path, '/\\');
                 if (file_exists($path)) {
                     $full_path = Less_Environment::normalizePath($path);
                     $uri = Less_Environment::normalizePath(dirname($rooturi . $evald_path));
                     return array($full_path, $uri);
                 } elseif (file_exists($path . '.less')) {
                     $full_path = Less_Environment::normalizePath($path . '.less');
                     $uri = Less_Environment::normalizePath(dirname($rooturi . $evald_path . '.less'));
                     return array($full_path, $uri);
                 }
             }
         }
     }
 }
开发者ID:PhantomOfTheOpera,项目名称:coolroom_code,代码行数:43,代码来源:Import.php

示例5: compile

 /**
  * @param Less_Functions $ctx
  */
 public function compile($ctx)
 {
     $val = $this->value->compile($ctx);
     if (!$this->isEvald) {
         // Add the base path if the URL is relative
         if (Less_Parser::$options['relativeUrls'] && $this->currentFileInfo && is_string($val->value) && Less_Environment::isPathRelative($val->value)) {
             $rootpath = $this->currentFileInfo['uri_root'];
             if (!$val->quote) {
                 $rootpath = preg_replace('/[\\(\\)\'"\\s]/', '\\$1', $rootpath);
             }
             $val->value = $rootpath . $val->value;
         }
         $val->value = Less_Environment::normalizePath($val->value);
     }
     return new Less_Tree_URL($val, $this->currentFileInfo, true);
 }
开发者ID:Tommar,项目名称:vino2,代码行数:19,代码来源:less.php


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