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


PHP JSMin::min方法代码示例

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


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

示例1: minify

 /**
  * Minify Javascript.
  *
  * @param string $js Javascript to be minified
  * @return string
  */
 public static function minify($js, $pic = false)
 {
     $jsmin = new JSMin($js, $pic);
     $min = $jsmin->min();
     unset($jsmin);
     return $min;
 }
开发者ID:kidaa30,项目名称:redcat,代码行数:13,代码来源:JSMin.php

示例2: minify

 function minify($js)
 {
     $jsmin = new JSMin($js);
     $output = $jsmin->min();
     if ($output === false) {
         return $js;
     }
     return $output;
 }
开发者ID:howardlei82,项目名称:IGSM-Website,代码行数:9,代码来源:jsmin.php

示例3: minify

	public static function minify($js, $level=3) {
		$jsmin = new JSMin($js, $level);
		return $jsmin->min();
	}
开发者ID:nizsheanez,项目名称:PolymorphCMS,代码行数:4,代码来源:JSMin.php

示例4: minify

 public function minify($aFiles, $sVersion, $bIsJS = true, $bDoInit = false, $bReturn = false, $bReplaceUrl = true)
 {
     static $oFormat = null;
     if (!isset($oFormat)) {
         $oFormat = Phpfox::getLib('parse.format');
     }
     if (!is_array($aFiles)) {
         $aFiles = array($aFiles);
     }
     $sHash = md5(implode($aFiles) . $sVersion);
     $sNameMd5 = md5(implode($aFiles) . $sVersion) . ($bIsJS ? '.js' : '.css');
     $sFilePath = PHPFOX_DIR_FILE . 'static' . PHPFOX_DS . $sNameMd5;
     $sUrl = Phpfox::getParam('core.path') . 'file/static/' . $sNameMd5;
     $bExists = false;
     if (Phpfox::getParam('core.allow_cdn') && Phpfox::getParam('core.push_jscss_to_cdn')) {
         $sCacheId = Phpfox::getLib('cache')->set(array('jscss', $sHash));
         if (Phpfox::getLib('cache')->get($sCacheId)) {
             $bExists = true;
         }
     } else {
         $bExists = file_exists($sFilePath);
     }
     if ($bExists) {
         if (Phpfox::getParam('core.allow_cdn') && Phpfox::getParam('core.push_jscss_to_cdn')) {
             $sUrl = Phpfox::getLib('cdn')->getUrl($sUrl);
         }
     } else {
         $sMinified = '';
         if ($bIsJS) {
             foreach ($aFiles as $sFile) {
                 $sOriginal = file_get_contents(PHPFOX_DIR . $sFile);
                 $oJsMin = new JSMin($sOriginal);
                 $sCompressed = $oJsMin->min();
                 // $sCompressed = $oFormat->helpJS($sCompressed);
                 $sMinified .= "\n /* {$sFile} */" . $sCompressed;
             }
         } else {
             $sHomeThemePath = Phpfox::getParam('core.force_https_secure_pages') && Phpfox::getParam('core.force_secure_site') ? 'https://' : 'http://';
             $sHomeThemePath .= Phpfox::getParam('core.host') . Phpfox::getParam('core.folder') . 'theme';
             foreach ($aFiles as $sFile) {
                 $sOriginal = file_get_contents(PHPFOX_DIR . $sFile);
                 $sCompressed = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), ' ', $sOriginal);
                 $sPathTo = substr($sFile, 0, strrpos($sFile, '/'));
                 $sPathTo = substr($sPathTo, 0, strrpos($sPathTo, '/'));
                 if (Phpfox::getParam('core.allow_cdn') && Phpfox::getParam('core.push_jscss_to_cdn') && defined('PHPFOX_IS_HOSTED_SCRIPT')) {
                     $sCompressed = str_replace('url(\'..', 'url(\'' . Phpfox::getCdnPath() . '' . $sPathTo, $sCompressed, $iCount);
                     $sCompressed = str_replace('url("..', 'url("' . Phpfox::getCdnPath() . '' . $sPathTo, $sCompressed, $iCount);
                     $sCompressed = str_replace('url(..', 'url(' . Phpfox::getCdnPath() . '' . $sPathTo, $sCompressed, $iCount);
                 } else {
                     if ($bReplaceUrl == true) {
                         $sCompressed = str_replace('url(\'..', 'url(\'../../' . $sPathTo, $sCompressed, $iCount);
                         $sCompressed = str_replace('url("..', 'url("../../' . $sPathTo, $sCompressed, $iCount);
                         $sCompressed = str_replace('url(..', 'url(../../' . $sPathTo, $sCompressed, $iCount);
                         $sCompressed = str_replace('../../theme', '' . $sHomeThemePath, $sCompressed, $iCount);
                     }
                 }
                 if ($bReplaceUrl == true) {
                     $sCompressed = str_replace('css/', 'image/', $sCompressed);
                 }
                 $sMinified .= $sCompressed;
             }
         }
         if ($bReturn == true) {
             return $sMinified;
         }
         if ($bIsJS && $bDoInit) {
             $sMinified .= "\n" . '$Core.init();';
         }
         file_put_contents($sFilePath, $sMinified);
         // if cdn enabled put it in cdn as well here
         if (Phpfox::getParam('core.allow_cdn') && Phpfox::getParam('core.push_jscss_to_cdn')) {
             Phpfox::getLib('cache')->save($sCacheId, '1');
             Phpfox::getLib('cdn')->put($sFilePath);
             $sUrl = Phpfox::getLib('cdn')->getUrl($sUrl);
         }
     }
     return $sUrl . $sVersion;
 }
开发者ID:Lovinity,项目名称:EQM,代码行数:78,代码来源:minimize.class.php

示例5: Minificar_JS_CSS

 public static function Minificar_JS_CSS()
 {
     if (file_exists(dirname(__FILE__) . '/Config/ArchivosMinify.php')) {
         include "CSSMin.php";
         include "JSMin.php";
         $MinDebug = "\n";
         //$MinDebug = "";
         $ArrayMin = (require dirname(__FILE__) . '/Config/ArchivosMinify.php');
         $StringJS = "";
         foreach ($ArrayMin["js"] as $Archivo) {
             $JSMin = new JSMin(file_get_contents(dirname(__FILE__) . $Archivo));
             $StringJS .= $JSMin->min() . $MinDebug;
         }
         file_put_contents(dirname(__FILE__) . "/Cache/devildrey33.min.js", $StringJS);
         $StringCSS = "";
         $CSSMin = new CSSmin();
         foreach ($ArrayMin["css"] as $Archivo) {
             $StringCSS .= $CSSMin->run(file_get_contents(dirname(__FILE__) . $Archivo));
         }
         file_put_contents(dirname(__FILE__) . "/Cache/devildrey33.min.css", $StringCSS);
         return "Cache actualizada!";
     } else {
         error_log("<span style='color:red'>Error!</span> devildrey33::Minificar_JS_CSS -> el archivo '/Config/ArchivosMinify.php' no existe.");
         return "Error del servidor";
     }
 }
开发者ID:devildrey33,项目名称:devildrey33,代码行数:26,代码来源:devildrey33.php

示例6: minify

 /**
  * Minify Javascript
  *
  * @param string $js Javascript to be minified
  * @return string
  */
 public static function minify($js)
 {
     // look out for syntax like "++ +" and "- ++"
     $p = '\\+';
     $m = '\\-';
     if (preg_match("/([{$p}{$m}])(?:\\1 [{$p}{$m}]| (?:{$p}{$p}|{$m}{$m}))/", $js)) {
         // likely pre-minified and would be broken by JSMin
         return $js;
     }
     $jsmin = new JSMin($js);
     return $jsmin->min();
 }
开发者ID:bigjoevtrj,项目名称:codeigniter-bootstrap,代码行数:18,代码来源:class.JSMin.inc.php

示例7: minify

 public static function minify($js)
 {
     /* Protect all datas inside blocks like :
      *	//<<
      *	...
      *	//!>>
      * Used to protect copyrights texts or already minimified JS
      */
     $matches = array();
     //augment pcre.backtrack_limit
     ini_set('pcre.backtrack_limit', 500000);
     preg_match_all("#\\/{2}<{2}(.*)\\/{2}\\!>{2}#Us", $js, $matches);
     //reset pcre.backtrack_limit
     ini_set('pcre.backtrack_limit', 100000);
     if (isset($matches[1]) && $matches[1]) {
         $return = '';
         $js = explode('//<<', $js);
         if (trim($js[0]) != '') {
             $jsminStart = new JSMin($js[0]);
             $return .= $jsminStart->min();
         }
         unset($js[0]);
         $js = array_values($js);
         foreach ($matches[1] as $key => $match) {
             $code = explode('//!>>', $js[$key]);
             $jsmin = new JSMin($code[1]);
             try {
                 $return .= $match . "\n" . $jsmin->min();
             } catch (JSMinException $e) {
                 CMS_grandFather::raiseError($e->getMessage());
                 $return .= $match . "\n" . $code[1];
             }
         }
         return $return;
     } else {
         $jsmin = new JSMin($js);
         try {
             return $jsmin->min();
         } catch (JSMinException $e) {
             CMS_grandFather::raiseError($e->getMessage());
             return $js;
         }
     }
 }
开发者ID:davidmottet,项目名称:automne,代码行数:44,代码来源:jsmin.php

示例8: minify

 static function minify($L)
 {
     $J = new JSMin($L);
     return $J->min();
 }
开发者ID:Rudianasaja,项目名称:cycommerce,代码行数:5,代码来源:NLSClientScript.php

示例9: minify_js

 private function minify_js($contents)
 {
     $jsmin = new JSMin($contents);
     $contents = $jsmin->min();
     return $contents;
 }
开发者ID:0x6C77,项目名称:minifier-php,代码行数:6,代码来源:class.loader.php

示例10: minify

 /**
  * Minify Javascript
  *
  * @uses __construct()
  * @uses min()
  * @param string $js Javascript to be minified
  * @return string
  */
 public static function minify($js, $nivel = 2, $cabecalho = "")
 {
     $jsmin = new JSMin($js, $nivel, $cabecalho);
     return $jsmin->min();
 }
开发者ID:romulo1984,项目名称:FacilMVC,代码行数:13,代码来源:MinifyJs.php

示例11: minify

 public static function minify($js, $filename = '')
 {
     static $instance;
     // this is a singleton
     if (!$instance) {
         $instance = new JSMin();
     }
     return $instance->min($js, $filename);
 }
开发者ID:sasha-adm-in,项目名称:project,代码行数:9,代码来源:JsMin.php

示例12: format_content

 /**
  * Formal CSS, LESS and JS content.
  */
 public function format_content($content)
 {
     if ('style' == $this->compiler['type']) {
         if ('less' == $this->compiler['format']) {
             if (!class_exists('Beans_Lessc')) {
                 require_once BEANS_API_PATH . 'compiler/vendors/lessc.php';
             }
             $less = new Beans_Lessc();
             $content = $less->compile($content);
         }
         if (!_beans_is_compiler_dev_mode()) {
             $content = $this->strip_whitespace($content);
         }
     }
     if ('script' == $this->compiler['type'] && !_beans_is_compiler_dev_mode() && $this->compiler['minify_js']) {
         if (!class_exists('JSMin')) {
             require_once BEANS_API_PATH . 'compiler/vendors/js-minifier.php';
         }
         $js_min = new JSMin($content);
         $content = $js_min->min();
     }
     return $content;
 }
开发者ID:Getbeans,项目名称:Beans,代码行数:26,代码来源:class-compiler.php

示例13: js_minify

/**
 * Minimise the given Javascript
 *
 * @param 	string		Javascript to minimise
 * @return 	string		Minimised Javascript
 */
function js_minify($js)
{
    if (strpos($js, 'no minify') !== false) {
        return $js;
    }
    require_code('jsmin');
    if (!class_exists('JSMin')) {
        return $js;
    }
    $jsmin = new JSMin($js);
    return $jsmin->min();
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:18,代码来源:css_and_js.php

示例14: makeJs

 public function makeJs()
 {
     require_once __DIR__ . '/../../Lib/JSMin.php';
     require_once __DIR__ . '/../../Lib/CSSmin.php';
     $Cdn = new Cdn($this->O);
     $debug_level = $this->O->glob('debug');
     if ($debug_level > 2) {
         $line_cr = "\r\n";
     } else {
         $line_cr = null;
     }
     foreach ($this->js as $key => $files) {
         foreach ($files as $file) {
             echo '<script src="' . $this->rw_cache($file) . '" type="text/javascript" ></script>' . $line_cr;
         }
     }
     if ($debug_level >= 2 && $this->O->glob('cache')) {
         foreach ($this->cachedJs as $key => $files) {
             foreach ($files as $file) {
                 echo '<script src="' . $this->rw_cache($file) . '" type="text/javascript" ></script>' . $line_cr;
             }
         }
         $this->cachedJs = array();
     } else {
         foreach ($this->cachedJs as $key => $files) {
             $sorted_files_ref = $files;
             sort($sorted_files_ref);
             $key = 'js_' . md5(implode('', $sorted_files_ref)) . '_' . count($files) . '_' . $this->O->glob('version') . self::$cache . '.js';
             if (!($cache = $Cdn->exist($key))) {
                 foreach ($files as $file) {
                     try {
                         // lazy loading fix
                         $srcfile = json_encode($file);
                         $cache .= "document._currentScript = document.createElement('script');";
                         $cache .= "document._currentScript.src = {$srcfile};";
                         $cache .= "document.currentScript = document._currentScript;";
                         $js = self::fileGetContents($file);
                         if ($this->O->glob('debug') < 3) {
                             $jsmin = new \JSMin($js);
                             $js = $jsmin->min();
                         }
                         $cache .= $js . $line_cr;
                     } catch (\Exception $e) {
                     }
                 }
                 $Cdn->put($key, $cache);
             }
             echo '<script src="' . $Cdn->url($key) . '" type="text/javascript" ></script>' . $line_cr;
             break;
         }
         $this->cachedJs = array();
     }
     foreach ($this->scriptInline as $v) {
         echo $v . $line_cr;
     }
     $this->scriptInline = array();
 }
开发者ID:4Publish,项目名称:4p_core,代码行数:57,代码来源:TemplateHeader.php

示例15: minify

 public static function minify($js, $noComments = TRUE)
 {
     $jsmin = new JSMin($js);
     $jsmin->noComments = $noComments;
     return $jsmin->min();
 }
开发者ID:remo,项目名称:miser,代码行数:6,代码来源:jsmin.php


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