本文整理汇总了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);
}
示例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));
}
示例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;
}
示例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);
}
}
}
}
}
示例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);
}