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


PHP Minify_CSS_UriRewriter::_currentDir方法代码示例

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


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

示例1: _rewrite

 /**
  * Rewrite file relative URIs as root relative in CSS files
  *
  * @param string $css
  *
  * @param string $currentDir The directory of the current CSS file.
  *
  * @param string $prependAbsolutePath
  *
  * @param string $prependAbsolutePathCallback
  *
  * @param string $docRoot The document root of the web site in which
  * the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']).
  *
  * @param array $symlinks (default = array()) If the CSS file is stored in
  * a symlink-ed directory, provide an array of link paths to
  * target paths, where the link paths are within the document root. Because
  * paths need to be normalized for this to work, use "//" to substitute
  * the doc root in the link paths (the array keys). E.g.:
  * <code>
  * array('//symlink' => '/real/target/path') // unix
  * array('//static' => 'D:\\staticStorage')  // Windows
  * </code>
  *
  * @param int $browserCacheId
  *
  * @param array $browserCacheExtensions
  *
  * @return string
  */
 private static function _rewrite($css, $currentDir, $prependAbsolutePath = null, $prependAbsolutePathCallback = null, $docRoot = null, $symlinks = array(), $browserCacheId = 0, $browserCacheExtensions = array())
 {
     self::$_docRoot = self::_realpath($docRoot ? $docRoot : $_SERVER['DOCUMENT_ROOT']);
     self::$_currentDir = self::_realpath($currentDir);
     self::$_prependAbsolutePath = $prependAbsolutePath;
     self::$_prependAbsolutePathCallback = $prependAbsolutePathCallback;
     self::$_symlinks = array();
     self::$_browserCacheId = $browserCacheId;
     self::$_browserCacheExtensions = $browserCacheExtensions;
     // normalize symlinks
     foreach ($symlinks as $link => $target) {
         $link = $link === '//' ? self::$_docRoot : str_replace('//', self::$_docRoot . '/', $link);
         $link = strtr($link, '/', DIRECTORY_SEPARATOR);
         self::$_symlinks[$link] = self::_realpath($target);
     }
     self::$debugText .= "docRoot    : " . self::$_docRoot . "\n" . "currentDir : " . self::$_currentDir . "\n";
     if (self::$_symlinks) {
         self::$debugText .= "symlinks : " . implode(', ', self::$_symlinks) . "\n";
     }
     self::$debugText .= "\n";
     $css = self::_trimUrls($css);
     // rewrite
     $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/', array(self::$className, '_processUriCB'), $css);
     $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/', array(self::$className, '_processUriCB'), $css);
     return $css;
 }
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:56,代码来源:UriRewriter.php

示例2: rewrite

    /**
     * Rewrite file relative URIs as root relative in CSS files
     * 
     * @param string $css
     * 
     * @param string $currentDir The directory of the current CSS file.
     * 
     * @param string $docRoot The document root of the web site in which 
     * the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']).
     * 
     * @param array $symlinks (default = array()) If the CSS file is stored in 
     * a symlink-ed directory, provide an array of link paths to
     * target paths, where the link paths are within the document root. Because 
     * paths need to be normalized for this to work, use "//" to substitute 
     * the doc root in the link paths (the array keys). E.g.:
     * <code>
     * array('//symlink' => '/real/target/path') // unix
     * array('//static' => 'D:\\staticStorage')  // Windows
     * </code>
     * 
     * @return string
     */
    static public function rewrite($css, $currentDir, $docRoot = null, $symlinks = array()) 
    {
        self::$_docRoot = self::_realpath(
            $docRoot ? $docRoot : $_SERVER['DOCUMENT_ROOT']
        );
        self::$_currentDir = self::_realpath($currentDir);
        self::$_symlinks = array();
        
        // normalize symlinks
        foreach ($symlinks as $link => $target) {
            $link = ($link === '//')
                ? self::$_docRoot
                : str_replace('//', self::$_docRoot . '/', $link);
            $link = strtr($link, '/', DIRECTORY_SEPARATOR);
            self::$_symlinks[$link] = self::_realpath($target);
        }
        
        self::$debugText .= "docRoot    : " . self::$_docRoot . "\n"
                          . "currentDir : " . self::$_currentDir . "\n";
        if (self::$_symlinks) {
            self::$debugText .= "symlinks : " . var_export(self::$_symlinks, 1) . "\n";
        }
        self::$debugText .= "\n";
        
        $css = self::_trimUrls($css);
        
        // rewrite
        $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
            ,array(self::$className, '_processUriCB'), $css);
        $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
            ,array(self::$className, '_processUriCB'), $css);

        return $css;
    }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:56,代码来源:UriRewriter.php

示例3: rewrite

    /**
     * Rewrite file relative URIs as root relative in CSS files
     * 
     * @param string $css
     * 
     * @param string $currentDir The directory of the current CSS file.
     * 
     * @param string $docRoot The document root of the web site in which 
     * the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']).
     * 
     * @param array $symlinks (default = array()) If the CSS file is stored in 
     * a symlink-ed directory, provide an array of link paths to
     * target paths, where the link paths are within the document root. Because 
     * paths need to be normalized for this to work, use "//" to substitute 
     * the doc root in the link paths (the array keys). E.g.:
     * <code>
     * array('//symlink' => '/real/target/path') // unix
     * array('//static' => 'D:\\staticStorage')  // Windows
     * </code>
     * 
     * @return string
     */
    public static function rewrite($css, $currentDir, $docRoot = null, $symlinks = array()) 
    {
        self::$_docRoot = $docRoot
            ? $docRoot
            : $_SERVER['DOCUMENT_ROOT'];
        self::$_docRoot = realpath(self::$_docRoot);
        self::$_currentDir = realpath($currentDir);
        self::$_symlinks = array();
        
        // normalize symlinks
        foreach ($symlinks as $link => $target) {
            $link = str_replace('//', realpath(self::$_docRoot), $link);
            $link = strtr($link, '/', DIRECTORY_SEPARATOR);
            self::$_symlinks[$link] = realpath($target);
        }
        
        $css = self::_trimUrls($css);
        
        // rewrite
        $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/'
            ,array(self::$className, '_uriCB'), $css);
        $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/'
            ,array(self::$className, '_uriCB'), $css);

        return $css;
    }
开发者ID:nizsheanez,项目名称:PolymorphCMS,代码行数:48,代码来源:UriRewriter.php

示例4: rewrite

 /**
  * Rewrite file relative URIs as root relative in CSS files
  * 
  * @param string $css
  * 
  * @param string $currentDir The directory of the current CSS file.
  * 
  * @param string $docRoot The document root of the web site in which 
  * the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']).
  * 
  * @return string
  */
 public static function rewrite($css, $currentDir, $docRoot = null, $prependPath = null)
 {
     self::$_docRoot = self::_realpath($docRoot ? $docRoot : $_SERVER['DOCUMENT_ROOT']);
     self::$_currentDir = self::_realpath($currentDir);
     self::$_prependPath = $prependPath ? $prependPath : '';
     self::$debugText .= "docRoot    : " . self::$_docRoot . "\n" . "currentDir : " . self::$_currentDir . "\n";
     //        if (self::$_symlinks) {
     //            self::$debugText .= "symlinks : " . var_export(self::$_symlinks, 1) . "\n";
     //        }
     self::$debugText .= "\n";
     $css = self::_trimUrls($css);
     // rewrite
     $css = preg_replace_callback('/@import\\s+(?:url)(.+);/', array(self::$className, '_processImportUriCB'), $css);
     $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/', array(self::$className, '_processUriCB'), $css);
     return $css;
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:28,代码来源:UriRewriter.php

示例5: rewrite

 /**
  * Rewrite file relative URIs as root relative in CSS files
  * 
  * @param string $css
  * 
  * @param string $currentDir The directory of the current CSS file.
  *
  * @param string $docRoot The document root of the web site in which 
  * the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']).
  * 
  * @return string
  */
 public static function rewrite($css, $currentDir, $docRoot = null)
 {
     self::$_docRoot = $docRoot ? $docRoot : $_SERVER['DOCUMENT_ROOT'];
     self::$_docRoot = realpath(self::$_docRoot);
     self::$_currentDir = realpath($currentDir);
     // remove ws around urls
     $css = preg_replace('/
             url\\(      # url(
             \\s*
             ([^\\)]+?)  # 1 = URI (really just a bunch of non right parenthesis)
             \\s*
             \\)         # )
         /x', 'url($1)', $css);
     // rewrite
     $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/', array('Minify_CSS_UriRewriter', '_uriCB'), $css);
     $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/', array('Minify_CSS_UriRewriter', '_uriCB'), $css);
     return $css;
 }
开发者ID:Jaree,项目名称:revive-adserver,代码行数:30,代码来源:UriRewriter.php

示例6: _processImportUriCB

 private static function _processImportUriCB($m)
 {
     $uri = trim($m[1], '()"\' ');
     //       decho(self::$_currentDir, 'currentDir');
     //       decho(self::$_docRoot, 'docRoot');
     // We want to grab the import.
     if (strpos($uri, '//') !== false) {
         $path = $uri;
     } elseif ($uri[0] == '/') {
         $path = self::_realpath(self::$_docRoot, $uri);
     } else {
         $path = realpath2(self::$_currentDir . '/' . trim($uri, '/\\'));
         if (substr_compare(self::$_docRoot, $path, 0, strlen($path)) != 0) {
             return "/* Error: {$uri} isn't in the webroot. */\n";
         } elseif (substr_compare($path, '.css', -4, 4, true) != 0) {
             return "/* Error: {$uri} must end in .css. */\n";
         }
     }
     $css = file_get_contents($path);
     // Not so fast, we've got to rewrite this file too. What's more, the current dir and path are different.
     $currentDirBak = self::$_currentDir;
     $newCurrentDir = realpath2($currentDirBak . realpath2(dirname($uri)));
     //       echo "
     //       currentDir: $currentDir,
     //       newCurrentDir: $newCurrentDir,
     //       docRoot: $docRoot
     //       uri:$uri\n";
     $css = self::rewrite($css, $newCurrentDir, self::$_docRoot);
     self::$_currentDir = $currentDirBak;
     return "/* @include url('{$uri}'); */\n" . $css;
 }
开发者ID:robhazkes,项目名称:Garden,代码行数:31,代码来源:UriRewriter.php


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