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


PHP Minify_CSS_UriRewriter::debugText方法代码示例

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


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

示例1: minify

 /**
  * Add line numbers in C-style comments
  *
  * This uses a very basic parser easily fooled by comment tokens inside
  * strings or regexes, but, otherwise, generally clean code will not be
  * mangled. URI rewriting can also be performed.
  *
  * @param string $content
  *
  * @param array $options available options:
  *
  * 'id': (optional) string to identify file. E.g. file name/path
  *
  * 'currentDir': (default null) if given, this is assumed to be the
  * directory of the current CSS file. Using this, minify will rewrite
  * all relative URIs in import/url declarations to correctly point to
  * the desired files, and prepend a comment with debugging information about
  * this process.
  *
  * @return string
  */
 public static function minify($content, $options = array())
 {
     $id = isset($options['id']) && $options['id'] ? $options['id'] : '';
     $content = str_replace("\r\n", "\n", $content);
     $lines = explode("\n", $content);
     $numLines = count($lines);
     // determine left padding
     $padTo = strlen((string) $numLines);
     // e.g. 103 lines = 3 digits
     $inComment = false;
     $i = 0;
     $newLines = array();
     while (null !== ($line = array_shift($lines))) {
         if ('' !== $id && 0 == $i % 50) {
             if ($inComment) {
                 array_push($newLines, '', "/* {$id} *|", '');
             } else {
                 array_push($newLines, '', "/* {$id} */", '');
             }
         }
         ++$i;
         $newLines[] = self::_addNote($line, $i, $inComment, $padTo);
         $inComment = self::_eolInComment($line, $inComment);
     }
     $content = implode("\n", $newLines) . "\n";
     // check for desired URI rewriting
     if (isset($options['currentDir'])) {
         Minify_CSS_UriRewriter::$debugText = '';
         $docRoot = isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT'];
         $symlinks = isset($options['symlinks']) ? $options['symlinks'] : array();
         $content = Minify_CSS_UriRewriter::rewrite($content, $options['currentDir'], $docRoot, $symlinks);
         $content = "/* Minify_CSS_UriRewriter::\$debugText\n\n" . Minify_CSS_UriRewriter::$debugText . "*/\n" . $content;
     }
     return $content;
 }
开发者ID:mrclay,项目名称:minify,代码行数:56,代码来源:Lines.php

示例2: minify

 /**
  * Add line numbers in C-style comments
  *
  * This uses a very basic parser easily fooled by comment tokens inside
  * strings or regexes, but, otherwise, generally clean code will not be 
  * mangled. URI rewriting can also be performed.
  *
  * @param string $content
  * 
  * @param array $options available options:
  * 
  * 'id': (optional) string to identify file. E.g. file name/path
  *
  * 'currentDir': (default null) if given, this is assumed to be the
  * directory of the current CSS file. Using this, minify will rewrite
  * all relative URIs in import/url declarations to correctly point to
  * the desired files, and prepend a comment with debugging information about
  * this process.
  * 
  * @return string 
  */
 public static function minify($content, $options = array())
 {
     $id = isset($options['id']) && $options['id'] ? $options['id'] : '';
     $content = str_replace("\r\n", "\n", $content);
     // Hackily rewrite strings with XPath expressions that are
     // likely to throw off our dumb parser (for Prototype 1.6.1).
     $content = str_replace('"/*"', '"/"+"*"', $content);
     $content = preg_replace('@([\'"])(\\.?//?)\\*@', '$1$2$1+$1*', $content);
     $lines = explode("\n", $content);
     $numLines = count($lines);
     // determine left padding
     $padTo = strlen((string) $numLines);
     // e.g. 103 lines = 3 digits
     $inComment = false;
     $i = 0;
     $newLines = array();
     while (null !== ($line = array_shift($lines))) {
         if ('' !== $id && 0 == $i % 50) {
             array_push($newLines, '', "/* {$id} */", '');
         }
         ++$i;
         $newLines[] = self::_addNote($line, $i, $inComment, $padTo);
         $inComment = self::_eolInComment($line, $inComment);
     }
     $content = implode("\n", $newLines) . "\n";
     // check for desired URI rewriting
     if (isset($options['currentDir'])) {
         //require _once MINIFY_MIN_DIR.'/Minify/CSS/UriRewriter.php';
         Minify_CSS_UriRewriter::$debugText = '';
         $content = Minify_CSS_UriRewriter::rewrite($content, $options['currentDir'], isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT'], isset($options['symlinks']) ? $options['symlinks'] : array());
         $content = "/* Minify_CSS_UriRewriter::\$debugText\n\n" . Minify_CSS_UriRewriter::$debugText . "*/\n" . $content;
     }
     return $content;
 }
开发者ID:nickschot,项目名称:minify-kohana,代码行数:55,代码来源:lines.php

示例3: test_Minify_CSS_UriRewriter

function test_Minify_CSS_UriRewriter()
{
    global $thisDir;
    Minify_CSS_UriRewriter::$debugText = '';
    $in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css');
    $expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp.css');
    $actual = Minify_CSS_UriRewriter::rewrite($in, $thisDir . '/_test_files/css_uriRewriter', $thisDir);
    $passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Input:\n\n{$in}\n";
        echo "\n---Output: " . strlen($actual) . " bytes\n\n{$actual}\n\n";
        if (!$passed) {
            echo "---Expected: " . strlen($expected) . " bytes\n\n{$expected}\n\n\n";
        }
        // show debugging only when test run directly
        echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText;
    }
    Minify_CSS_UriRewriter::$debugText = '';
    $in = '../../../../assets/skins/sam/sprite.png';
    $exp = '/yui/assets/skins/sam/sprite.png';
    $actual = Minify_CSS_UriRewriter::rewriteRelative($in, 'sf_root_dir\\web\\yui\\menu\\assets\\skins\\sam', 'sf_root_dir\\web');
    $passed = assertTrue($exp === $actual, 'Minify_CSS_UriRewriter : Issue 99');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Input:\n\n{$in}\n";
        echo "\n---Output: " . strlen($actual) . " bytes\n\n{$actual}\n\n";
        if (!$passed) {
            echo "---Expected: " . strlen($exp) . " bytes\n\n{$exp}\n\n\n";
        }
        // show debugging only when test run directly
        echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText;
    }
}
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:32,代码来源:test_Minify_CSS_UriRewriter.php

示例4: minify

 /**
  * Add line numbers in C-style comments
  *
  * This uses a very basic parser easily fooled by comment tokens inside
  * strings or regexes, but, otherwise, generally clean code will not be 
  * mangled. URI rewriting can also be performed.
  *
  * @param string $content
  * 
  * @param array $options available options:
  * 
  * 'id': (optional) string to identify file. E.g. file name/path
  *
  * 'currentDir': (default null) if given, this is assumed to be the
  * directory of the current CSS file. Using this, minify will rewrite
  * all relative URIs in import/url declarations to correctly point to
  * the desired files, and prepend a comment with debugging information about
  * this process.
  * 
  * @return string 
  */
 public static function minify($content, $options = array())
 {
     $id = isset($options['id']) && $options['id'] ? $options['id'] : '';
     $content = str_replace("\r\n", "\n", $content);
     $lines = explode("\n", $content);
     $numLines = count($lines);
     // determine left padding
     $padTo = strlen($numLines);
     $inComment = false;
     $i = 0;
     $newLines = array();
     while (null !== ($line = array_shift($lines))) {
         if ('' !== $id && 0 == $i % 50) {
             array_push($newLines, '', "/* {$id} */", '');
         }
         ++$i;
         $newLines[] = self::_addNote($line, $i, $inComment, $padTo);
         $inComment = self::_eolInComment($line, $inComment);
     }
     $content = implode("\n", $newLines) . "\n";
     // check for desired URI rewriting
     if (isset($options['currentDir'])) {
         require_once W3TC_LIB_MINIFY_DIR . '/Minify/CSS/UriRewriter.php';
         Minify_CSS_UriRewriter::$debugText = '';
         $content = Minify_CSS_UriRewriter::rewrite($content, $options['currentDir'], isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT'], isset($options['symlinks']) ? $options['symlinks'] : array(), isset($options['browserCacheId']) ? $options['browserCacheId'] : 0, isset($options['browserCacheExtensions']) ? $options['browserCacheExtensions'] : array());
         $content = "/* Minify_CSS_UriRewriter::\$debugText\n\n" . Minify_CSS_UriRewriter::$debugText . "*/\n" . $content;
     } elseif (isset($options['prependRelativePath'])) {
         require_once W3TC_LIB_MINIFY_DIR . '/Minify/CSS/UriRewriter.php';
         Minify_CSS_UriRewriter::$debugText = '';
         $content = Minify_CSS_UriRewriter::prepend($content, $options['prependRelativePath'], isset($options['browserCacheId']) ? $options['browserCacheId'] : 0, isset($options['browserCacheExtensions']) ? $options['browserCacheExtensions'] : array());
     }
     return $content;
 }
开发者ID:niko-lgdcom,项目名称:archives,代码行数:54,代码来源:Lines.php

示例5: _processImportUriCB

 private static function _processImportUriCB($m)
 {
     $uri = trim($m[1], '()"\' ');
     // 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.
     $bak = array(self::$_currentDir, self::$_prependPath, self::$_docRoot, self::$debugText);
     self::$debugText = '';
     if (IsUrl($path)) {
         $newCurrentDir = $path;
         $newDocRoot = $path;
     } else {
         $newDocRoot = self::$_docRoot;
         $newCurrentDir = realpath2($currentDirBak . realpath2(dirname($uri)));
     }
     $css = self::rewrite($css, $newCurrentDir, $newDocRoot);
     list(self::$_currentDir, self::$_prependPath, self::$_docRoot, self::$debugText) = $bak;
     return "/* @include url('{$uri}'); */\n" . $css;
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:31,代码来源:UriRewriter.php


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