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


PHP Assets::minify方法代码示例

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


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

示例1: compress

 /**
  * Compress source to deployment format
  * @usage php public/index.php minify
  */
 static function compress()
 {
     echo chr(27) . "[96mCompressing index.php: " . chr(27) . "[0m";
     $data = file_get_contents(self::$sourceFile);
     if (empty($data)) {
         die(chr(27) . "[91munable to read " . self::$sourceFile . chr(27) . "[0m\n");
     }
     //! uncomment self check
     $data = str_replace('//$c=__FILE__;if(filesize', '$c=__FILE__;if(filesize', $data);
     //! remove benchmarking code
     $data = preg_replace('|/\\*! BENCHMARK START \\*/.*?/\\*! BENCHMARK END \\*/|ims', "", $data);
     $data = preg_replace('/(self|Core)::bm\\([^;]+;/ims', "", $data);
     //! keep license comment
     $i = strpos($data, "*/") + 2;
     //! make sure minifier is not turned off
     Core::$core->nominify = false;
     $code = substr($data, $i);
     $out = substr($data, 0, $i) . "\n" . Assets::minify($code, "php");
     $l = strlen($out);
     if ($l > 99999) {
         die(chr(27) . "[91mfile too big, " . $l . " bytes" . chr(27) . "[0m\n");
     }
     //! replace file size
     $out = str_replace("c)!=99999||'", "c)!=" . sprintf("%5d", $l) . "||'", $out);
     //! calculate new checksum
     $chksum = sha1(preg_replace("/\\'([^\\']+)\\'\\!\\=sha1/", "''!=sha1", $out));
     $out = preg_replace("/\\'([^\\']+)\\'\\!\\=sha1/", "'" . $chksum . "'!=sha1", $out);
     $old = @filesize(self::$deployFile);
     //! write out deployment file
     if (!file_put_contents(self::$deployFile, $out)) {
         die(chr(27) . "[91munable to write " . self::$deployFile . chr(27) . "[0m\n");
     }
     echo $chksum . " " . strlen($out) . chr(27) . "[9" . (strlen($out) > $old ? "1" : "4") . "m (" . (strlen($out) > $old ? "+" : "") . (strlen($out) - $old) . ") " . chr(27) . "[92mOK" . chr(27) . "[0m\n";
 }
开发者ID:bztsrc,项目名称:phppe3,代码行数:38,代码来源:Repository.php

示例2: minify

 /**
  * 
  * @param boolean $js_footer
  * @return \KodiCMS_Meta
  */
 public function minify($js_footer = FALSE)
 {
     list($css_cache, $js_cache) = Assets::minify();
     if (!empty($css_cache)) {
         $this->css('cahce', $css_cache);
     }
     if (!empty($js_cache)) {
         $this->js('cahce', $js_cache, NULL, $js_footer);
     }
     return $this;
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:16,代码来源:meta.php

示例3: output

 public static function output(&$txt, $ap = "")
 {
     $o = Core::$core->output;
     Http::mime(!empty(self::$o['app']->mimetype) ? self::$o['app']->mimetype : 'text/' . ($o ? $o : 'html'), false);
     if ($o) {
         $c = @glob('vendor/phppe/*/out/' . $o . '_header.php');
         if (!empty($c[0])) {
             include_once $c[0];
         } elseif ($o == 'html') {
             $P = empty(Core::$core->nopanel) && Core::$user->has('panel');
             $I = basename(__FILE__) . '/';
             if ($I == 'index.php/') {
                 $I = '';
             }
             $d = 'http' . (Core::$core->sec ? 's' : '') . '://' . Core::$core->base;
             echo "<!DOCTYPE HTML>\n<html lang='" . Core::$client->lang . "'" . (!empty(Core::$l['rtl']) ? " dir='rtl'" : '') . '>' . '<head><title>' . (!empty(self::$o['app']->title) ? self::$o['app']->title : (Core::$core->title ? Core::$core->title : 'PHPPE' . VERSION)) . '</title>' . "<base href='{$d}'/><meta charset='utf-8'/>\n<meta name='Generator' content='PHPPE" . VERSION . "'/>\n";
             foreach (array_merge(self::$hdr['meta'], !empty(self::$o['app']->meta) ? self::$o['app']->meta : []) as $k => $m) {
                 if (!is_array($m)) {
                     $m = [$m, "name"];
                 }
                 if ($k && !empty($m[0]) && !empty($m[1])) {
                     echo "<meta " . $m[1] . "='{$k}' content='" . htmlspecialchars($m[0]) . "'/>\n";
                 }
             }
             self::$hdr['link'][!empty(self::$o['app']->favicon) ? self::$o['app']->favicon : 'favicon.ico'] = 'shortcut icon';
             foreach (self::$hdr['link'] as $k => $m) {
                 if (!empty($m) && $m != 'js') {
                     echo "<link rel='{$m}' href='" . $k . "'/>\n";
                 }
             }
             $O = "<style media='all'>\n";
             $d = "@import url('%s');\n";
             $N = Core::$core->base . Core::$core->url . '/' . Core::$user->id . '/' . Core::$client->lang;
             $e = 'css';
             if ($P) {
                 $O .= sprintf($d, $I . "?cache={$e}");
             }
             if (!empty(self::$hdr['css'])) {
                 if (!empty(Cache::$mc) && empty(Core::$core->noaggr)) {
                     $n = sha1($N . "_{$e}");
                     if (empty(Cache::get("c_{$n}", true))) {
                         $da = '';
                         foreach (self::$hdr['css'] as $u => $v) {
                             if ($v && substr($v, -3) != 'php' && $u[0] != '?') {
                                 $da .= Assets::minify(file_get_contents($v), $e) . "\n";
                             }
                         }
                         Cache::set("c_{$n}", ['m' => "text/{$e}", 'd' => $da], 0, true);
                     }
                     $O .= sprintf($d, $I . "?cache={$n}");
                     foreach (self::$hdr['css'] as $u => $v) {
                         if ($v && ($u[0] == '?' || substr($v, -3) == 'php')) {
                             $O .= sprintf($d, ($u[0] == '?' ? '' : $I . "{$e}/") . $u);
                         }
                     }
                 } else {
                     foreach (self::$hdr['css'] as $u => $v) {
                         if ($v) {
                             $O .= sprintf($d, ($u[0] == '?' ? '' : $I . "{$e}/") . $u);
                         }
                     }
                 }
             }
             $O .= "</style>\n";
             echo "{$O}</head>\n<body>\n";
             if ($P) {
                 $H = " class='sub' style='visibility:hidden;' onmousemove='return pe_w();'";
                 $O = "<div id='pe_p'><a href='" . url('/') . "'><img src='{$I}?cache=logo' alt='PHPPE" . VERSION . "' style='margin:3px 10px -3px 10px;float:left;'></a><div class='menu'>";
                 $x = 0;
                 if (!empty(self::$menu)) {
                     foreach (self::$menu as $e => $L) {
                         @(list($ti, $a) = explode('@', $e));
                         if ($a && !Core::$user->has($a)) {
                             continue;
                         }
                         $a = 0;
                         if (is_array($L)) {
                             $l = $L[array_keys($L)[0]];
                         } else {
                             $l = $L;
                         }
                         $U = Core::$core->url;
                         if (substr($l, 0, strlen($U)) == $U) {
                             $a = 1;
                         } else {
                             $d = explode('/', $l);
                             if ((!empty($ap) ? $ap : Core::$core->app) == (!empty($d[0]) ? $d[0] : 'index')) {
                                 $a = 1;
                             }
                             unset($d);
                         }
                         if (is_array($L)) {
                             $O .= "<div id='pe_m{$x}'{$H}><ul>";
                             foreach ($L as $t => $l) {
                                 if ($t) {
                                     @(list($Y, $A) = explode('@', $t));
                                     if (empty($A) || Core::$user->has($A)) {
                                         $O .= "<li onclick=\"document.location.href='" . $I . "{$l}';\"><a href='" . $I . "{$l}'>" . htmlspecialchars(L($Y)) . '</a></li>';
                                     }
                                 }
//.........这里部分代码省略.........
开发者ID:bztsrc,项目名称:phppe3,代码行数:101,代码来源:index.php


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