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


PHP Converter::detractSword方法代码示例

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


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

示例1: do_minify

function do_minify($content)
{
    global $config;
    $c = File::open(__DIR__ . DS . 'states' . DS . 'config.txt')->unserialize();
    $url = $config->protocol . $config->host;
    // Minify HTML
    if (isset($c['html_minifier'])) {
        $config->html_minifier = true;
        Config::set('html_minifier', $config->html_minifier);
        $content = Converter::detractSkeleton($content);
    }
    // Minify URL
    if (isset($c['url_minifier']) && Text::check($content)->has('="' . $url)) {
        $content = str_replace(array('="' . $url . '"', '="' . $url . '/', '="' . $url . '?', '="' . $url . '#'), array('="/"', '="/', '="?', '="#'), $content);
    }
    // Minify Embedded CSS
    if (isset($c['css_minifier'])) {
        $content = preg_replace_callback('#<style(>| .*?>)([\\s\\S]*?)<\\/style>#i', function ($matches) use($config, $c, $url) {
            $css = Converter::detractShell($matches[2]);
            if (isset($c['url_minifier'])) {
                $css = preg_replace('#(?<=[\\s:])(src|url)\\(' . preg_quote($url, '/') . '#', '$1(', $css);
            }
            return '<style' . $matches[1] . $css . '</style>';
        }, $content);
    }
    // Minify Embedded JavaScript
    if (isset($c['js_minifier'])) {
        $content = preg_replace_callback('#<script(>| .*?>)([\\s\\S]*?)<\\/script>#i', function ($matches) {
            $js = Converter::detractSword($matches[2]);
            return '<script' . $matches[1] . $js . '</script>';
        }, $content);
    }
    return $content;
}
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:34,代码来源:launch.php

示例2: do_minify

function do_minify($content)
{
    global $config;
    $c_minify = $config->states->{'plugin_' . md5(File::B(__DIR__))};
    $url = $config->protocol . $config->host;
    // Minify HTML
    if (isset($c_minify->html_minify)) {
        Config::set('html_minify', true);
        $content = Converter::detractSkeleton($content);
    }
    // Minify URL
    if (isset($c_minify->url_minify) && Text::check($content)->has('="' . $url)) {
        Config::set('url_minify', true);
        $content = str_replace(array('="' . $url . '"', '="' . $url . '/', '="' . $url . '?', '="' . $url . '#'), array('="/"', '="/', '="?', '="#'), $content);
    }
    // Minify Embedded CSS
    if (isset($c_minify->css_minify)) {
        Config::set('css_minify', true);
        $content = preg_replace_callback('#<style(>| .*?>)([\\s\\S]*?)<\\/style>#i', function ($matches) use($config, $c_minify, $url) {
            $css = Converter::detractShell($matches[2]);
            if (isset($c_minify->url_minify)) {
                $css = preg_replace('#(?<=[\\s:])(src|url)\\(' . preg_quote($url, '/') . '#', '$1(', $css);
            }
            return '<style' . $matches[1] . $css . '</style>';
        }, $content);
    }
    // Minify Embedded JavaScript
    if (isset($c_minify->js_minify)) {
        Config::set('js_minify', true);
        $content = preg_replace_callback('#<script(>| .*?>)([\\s\\S]*?)<\\/script>#i', function ($matches) {
            $js = Converter::detractSword($matches[2]);
            return '<script' . $matches[1] . $js . '</script>';
        }, $content);
    }
    return $content;
}
开发者ID:AdeHaze,项目名称:mecha-cms,代码行数:36,代码来源:launch.php

示例3: merge

 public static function merge($path, $name = null, $addon = "", $call = null)
 {
     $path = is_string($path) && strpos($path, ';') !== false ? explode(';', $path) : (array) $path;
     $the_path = ASSET . DS . File::path($name);
     $the_path_log = SYSTEM . DS . 'log' . DS . 'asset.' . str_replace(array(ASSET . DS, DS), array("", '__'), $the_path) . '.log';
     $is_valid = true;
     if (!file_exists($the_path_log)) {
         $is_valid = false;
     } else {
         $the_path_time = explode("\n", file_get_contents($the_path_log));
         if (count($the_path_time) !== count($path)) {
             $is_valid = false;
         } else {
             foreach ($the_path_time as $i => $time) {
                 $p = self::path($path[$i]);
                 if (!file_exists($p) || (int) filemtime($p) !== (int) $time) {
                     $is_valid = false;
                     break;
                 }
             }
         }
     }
     $time = "";
     $content = "";
     $e = File::E($name);
     if (!file_exists($the_path) || !$is_valid) {
         if (Text::check($e)->in(array('gif', 'jpeg', 'jpg', 'png'))) {
             foreach ($path as $p) {
                 if (!self::ignored($p)) {
                     $p = self::path($p);
                     if (file_exists($p)) {
                         $time .= filemtime($p) . "\n";
                     }
                 }
             }
             File::write(trim($time))->saveTo($the_path_log);
             Image::take($path)->merge()->saveTo($the_path);
         } else {
             foreach ($path as $p) {
                 if (!self::ignored($p)) {
                     $p = self::path($p);
                     if (file_exists($p)) {
                         $time .= filemtime($p) . "\n";
                         $c = file_get_contents($p);
                         if (strpos(File::B($p), '.min.') === false) {
                             if (strpos(File::B($the_path), '.min.css') !== false) {
                                 $content .= Converter::detractShell($c) . "\n";
                             } else {
                                 if (strpos(File::B($the_path), '.min.js') !== false) {
                                     $content .= Converter::detractSword($c) . "\n";
                                 } else {
                                     $content .= $c . "\n\n";
                                 }
                             }
                         } else {
                             $content .= $c . "\n\n";
                         }
                     }
                 }
             }
             File::write(trim($time))->saveTo($the_path_log);
             File::write(trim($content))->saveTo($the_path);
         }
     }
     if (is_null($call)) {
         $call = Mecha::alter($e, array('css' => 'stylesheet', 'js' => 'javascript', 'gif' => 'image', 'jpeg' => 'image', 'jpg' => 'image', 'png' => 'image'));
     }
     return call_user_func_array('self::' . $call, array($the_path, $addon));
 }
开发者ID:razordaze,项目名称:mecha-cms,代码行数:69,代码来源:asset.php

示例4: merge

 public static function merge($path, $name = null, $addon = "", $call = null)
 {
     $the_path = strpos($name, ROOT) === 0 ? File::path($name) : ASSET . DS . File::path($name);
     $the_log = LOG . DS . 'asset.' . str_replace(array(ASSET . DS, DS), array("", '__'), $the_path) . '.log';
     $is_valid = true;
     if (!file_exists($the_log)) {
         $is_valid = false;
     } else {
         $the_time = explode("\n", file_get_contents($the_log));
         if (count($the_time) !== count($path)) {
             $is_valid = false;
         } else {
             foreach ($the_time as $i => $unix) {
                 $p = self::path($path[$i]);
                 if (!file_exists($p) || (int) filemtime($p) !== (int) $unix) {
                     $is_valid = false;
                     break;
                 }
             }
         }
     }
     $unix = "";
     $content = "";
     $e = File::E($name);
     if (!file_exists($the_path) || !$is_valid) {
         if (Text::check($e)->in(array('gif', 'jpeg', 'jpg', 'png'))) {
             foreach ($path as &$p) {
                 $p = Filter::colon('asset:source', $p);
                 if (!self::ignored($p) && ($p = Filter::colon('asset:path', self::path($p, false)))) {
                     $unix .= filemtime($p) . "\n";
                 }
             }
             File::write(trim($unix))->saveTo($the_log);
             Image::take($path)->merge()->saveTo($the_path);
         } else {
             foreach ($path as $p) {
                 $p = Filter::colon('asset:source', $p);
                 if (!self::ignored($p) && ($p = Filter::colon('asset:path', self::path($p, false)))) {
                     $unix .= filemtime($p) . "\n";
                     $c = Filter::apply('asset:input', file_get_contents($p) . "\n", $p);
                     if (strpos(File::B($p), '.min.') === false) {
                         if (strpos(File::B($the_path), '.min.css') !== false) {
                             $c = Converter::detractShell($c);
                         } else {
                             if (strpos(File::B($the_path), '.min.js') !== false) {
                                 $c = Converter::detractSword($c);
                             } else {
                                 $c = $c . "\n";
                             }
                         }
                         $content .= Filter::apply('asset:output', $c, $p);
                     } else {
                         $content .= Filter::apply('asset:output', $c . "\n", $p);
                     }
                 }
             }
             File::write(trim($unix))->saveTo($the_log);
             File::write(trim($content))->saveTo($the_path);
         }
     }
     if (is_null($call)) {
         $call = Mecha::alter($e, array('css' => 'stylesheet', 'js' => 'javascript', 'gif' => 'image', 'jpeg' => 'image', 'jpg' => 'image', 'png' => 'image'));
     }
     return call_user_func('self::' . $call, $the_path, $addon);
 }
开发者ID:AdeHaze,项目名称:mecha-cms,代码行数:65,代码来源:asset.php


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