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


PHP JSMin类代码示例

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


在下文中一共展示了JSMin类的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: get_js_html

 private function get_js_html($cachefile)
 {
     if (Configure::read('debug') > 0) {
         $ret = "";
         foreach ($this->libs['js'] as $lib) {
             $ret .= $this->Javascript->link($lib);
         }
         return $ret;
     }
     if (file_exists($this->cachePath['js'] . '/' . $cachefile)) {
         return $this->Javascript->link($cachefile);
     }
     // Get the content
     $file_content = '';
     foreach ($this->libs['js'] as $lib) {
         $file_content .= "\n\n" . file_get_contents($this->basePath['js'] . '/' . $lib);
     }
     // If compression is enable, compress it !
     if ($this->__options['js']['enableCompression']) {
         App::import('Vendor', 'jsmin/jsmin');
         $file_content = trim(JSMin::minify($file_content));
     }
     // Get inline code if exist
     // Do it after jsmin to preserve variable's names
     if (!empty($this->inline_code['js'])) {
         foreach ($this->inline_code['js'] as $inlineJs) {
             $file_content .= "\n\n" . $inlineJs;
         }
     }
     if ($fp = fopen($this->cachePath['js'] . '/' . $cachefile, 'wb')) {
         fwrite($fp, $file_content);
         fclose($fp);
     }
     return $this->Javascript->link($cachefile);
 }
开发者ID:acerato,项目名称:cntcetp,代码行数:35,代码来源:combinator.php

示例4: pack

 public static function pack($compression = 'none', $code = '')
 {
     if (!$code) {
         throw new PHPJS_Exception('No code to pack');
         return false;
     }
     switch ($compression) {
         case 'packed':
             require_once dirname(__FILE__) . '/Pack/class.JavaScriptPacker.php';
             $packer = new JavaScriptPacker($code, 'Normal', true, false);
             $code = $packer->pack();
             break;
         case 'minified':
             require_once dirname(__FILE__) . '/Pack/jsmin.php';
             $code = JSMin::minify($code);
             break;
         case 'none':
             break;
         default:
             throw new PHPJS_Exception('No such packer: "' . $compression . '"');
             return false;
             break;
     }
     return '// Compression: ' . $compression . "\n\n" . $code;
 }
开发者ID:primeminister,项目名称:phpjs,代码行数:25,代码来源:Pack.php

示例5: compile

 function compile()
 {
     $output = $this->CI->output->get_output();
     // get <head> contents
     $matches = array();
     preg_match('#<head>(.*?)<\\/head>#si', $output, $matches);
     // head contents
     $head = $matches[1];
     // get JS includes via <script> references
     preg_match_all('#<script(.*?)src="(.*?)"(.*?)>(.*?)<\\/script>#si', $head, $matches);
     $js_includes = $matches[2];
     // delete non-local includes
     foreach ($js_includes as $key => $script) {
         if (strpos($script, '//') !== FALSE and strpos($script, $this->CI->config->item('base_url')) === FALSE) {
             // this script is external (has "//") and it's not just a domain reference to this site
             unset($js_includes[$key]);
         }
     }
     if (!empty($js_includes)) {
         $this->load->library('JSMin');
         // minify!
         $js_compiled = '';
         foreach ($js_includes as $script) {
             // get the file
             $js_compiled .= JSMin::minify($script);
         }
     }
     // TODO:
     // - load the files for minification
     //		- this includes using the base_href tag if one exists, otherwise loading paths relative to the domain or
     //		  using the full script URL if it's in that format
     // - replace old <script> references with one big reference
     // return the output
 }
开发者ID:Rotron,项目名称:hero,代码行数:34,代码来源:head_compile.php

示例6: Amango_Asset

/**
 * Emoji表情解析
 * @return string
 * @param [string] [$str] [将字符串中的[E537] 这类的emoji标签【仅支持SB Unicode】转化为Unicode值 ]
 *        emoji标签 详情网址: http://punchdrunker.github.io/iOSEmoji/table_html/index.html
 */
function Amango_Asset($options, $type = 'js')
{
    $path = './Data/js_cache/' . md5($options) . '.js';
    if (!is_file($path)) {
        //静态资源地址
        $files = explode(',', $options);
        $content = '';
        foreach ($files as $val) {
            $content .= file_get_contents('.' . str_replace(__ROOT__, '', $val));
        }
        import('Common.ORG.JSMin');
        $JSMin = new JSMin();
        file_put_contents($path, $JSMin->minify($content));
    }
    echo '<script type="text/javascript" src="' . $path . '?' . time() . '"></script>';
}
开发者ID:wmk223,项目名称:amango_V3,代码行数:22,代码来源:laravel.php

示例7: minify

 public function minify($inPath, $outPath)
 {
     $extension = $this->getExtension($inPath);
     echo basename($inPath) . ' -> ' . basename($outPath) . '...';
     $inText = file_get_contents($inPath);
     if ($inText === false) {
         $this->error("Unable to open file {$inPath} for reading.");
         exit(1);
     }
     $outFile = fopen($outPath, 'w');
     if (!$outFile) {
         $this->error("Unable to open file {$outPath} for writing.");
         exit(1);
     }
     switch ($extension) {
         case 'js':
             $outText = JSMin::minify($inText);
             break;
         default:
             $this->error("No minifier defined for extension \"{$extension}\"");
     }
     fwrite($outFile, $outText);
     fclose($outFile);
     echo " ok\n";
 }
开发者ID:rocLv,项目名称:conference,代码行数:25,代码来源:minify.php

示例8: minify

 public function minify()
 {
     if ($this->contentType != 'text/css') {
         G::LoadThirdParty('jsmin', 'jsmin');
         $this->content = JSMin::minify($this->content);
     }
 }
开发者ID:emildev35,项目名称:processmaker,代码行数:7,代码来源:class.helper.php

示例9: jsAction

 /**
  * Минификация яваскриптов
  * 
  * @return void
  */
 public function jsAction()
 {
     $this->_response->setHeader('Content-Type', 'text/javascript', true);
     if (isset($this->_params['files'])) {
         $files = explode(',', $this->_params['files']);
         foreach ($files as $key => $file) {
             $file = $this->_jsdir . trim($file) . '.js';
             if (file_exists($file)) {
                 $files[$key] = $file;
             }
         }
         if (!empty($files)) {
             $cacheid = 'minify_js_' . md5(implode(',', $files));
             $this->_cache->setMasterFiles($files);
             if ($this->_cache->test($cacheid)) {
                 $this->_response->setBody($this->_cache->load($cacheid));
             } else {
                 require_once 'Phorm/Plugin/jsmin.php';
                 $str = '';
                 foreach ($files as $file) {
                     $str .= file_get_contents($file) . PHP_EOL;
                 }
                 $js = JSMin::minify($str);
                 $this->_cache->save($js, $cacheid);
                 $this->_response->setBody($js);
             }
         }
     }
 }
开发者ID:ei-grad,项目名称:phorm,代码行数:34,代码来源:Minify.php

示例10: minifyJs

 public static function minifyJs(array $jsFiles)
 {
     if (true) {
         foreach ($jsFiles as $path) {
             $pathInfo = pathinfo($path);
             if (strpos($path, 'js/xenforo/') !== false) {
                 // ignore xenforo files
                 continue;
             }
             $dirName = $pathInfo['dirname'];
             $realDirName = realpath($dirName);
             $fullDirName = realpath($realDirName . '/full');
             $baseName = $pathInfo['basename'];
             $minPath = $realDirName . '/' . $baseName;
             $fullPath = $fullDirName . '/' . $baseName;
             if (file_exists($fullPath) and (!file_exists($minPath) or filemtime($fullPath) > filemtime($minPath))) {
                 $fullContents = file_get_contents($fullPath);
                 if (strpos($fullContents, '/* no minify */') === false) {
                     require_once dirname(__FILE__) . '/../Lib/jsmin-php/jsmin.php';
                     $minified = JSMin::minify($fullContents);
                 } else {
                     // the file requested not to be minify... (debugging?)
                     $minified = $fullContents;
                 }
                 self::writeFile($minPath, $minified, false, false);
             }
         }
     }
 }
开发者ID:maitandat1507,项目名称:DevHelper,代码行数:29,代码来源:File.php

示例11: moodbile_performance_minify_js

function moodbile_performance_minify_js($js)
{
    global $CFG;
    require_once $CFG['basepath'] . 'misc/jsmin.php';
    $js = JSMin::minify($js);
    return $js;
}
开发者ID:ratheep,项目名称:moodbile,代码行数:7,代码来源:performance.lib.php

示例12: minifyjs

 /** 
  * minify js and return js link
  * if minify is disabled: return direct js links
  *
  * @return string with html tag
  * @param array $javascripts with js files
  */
 public function minifyjs($javascripts)
 {
     if (Zend_Registry::get('config')->cache->enable == 1 && Zend_Registry::get('config')->cache->minifyjs == 1) {
         // check file
         $target = Zend_Registry::get('config')->pub->path . 'javascript/' . Zend_Registry::get('config')->cache->minifiedjsfile;
         $targeturl = 'javascript/' . Zend_Registry::get('config')->cache->minifiedjsfile;
         if (file_exists($target)) {
             return "<script type=\"text/javascript\" src=\"" . $targeturl . "\"></script>\n";
         }
         // load and minify files
         $all = "";
         foreach ($javascripts as $js) {
             $jscontent = file_get_contents(Zend_Registry::get('config')->pub->path . $js);
             $jscontent = JSMin::minify($jscontent);
             $all = $all . "\n\n// " . $js . "\n" . $jscontent;
         }
         file_put_contents($target, $all);
         return "<script type=\"text/javascript\" src=\"" . $targeturl . "\"></script>\n";
     } else {
         $ret = "";
         foreach ($javascripts as $js) {
             $ret = $ret . "<script type=\"text/javascript\" src=\"" . $js . "\"></script>\n";
         }
         return $ret;
     }
 }
开发者ID:google-code-backups,项目名称:rsslounge,代码行数:33,代码来源:Minifyjs.php

示例13: addjstext

function addjstext($output, $minify = true)
{
    if ($minify == true && (MINIFY == true || MINIFY == 1)) {
        $output = JSMin::minify($output);
    }
    return $output;
}
开发者ID:richpanzer,项目名称:ODS-Mobile---Supplement,代码行数:7,代码来源:functions.php

示例14: beforeAction

 public function beforeAction($action)
 {
     $base = Cshop::$rootpath;
     $jsfilename = $base . "/static/cache/final.js";
     if (!file_exists($jsfilename)) {
         $filename = $base . "/static/js/jquery.js";
         $js = file_get_contents($filename);
         $filename = $base . "/static/js/jquery-ui.js";
         $js .= file_get_contents($filename);
         $filename = $base . "/static/js/jquery.mousewheel.js";
         $js .= file_get_contents($filename);
         $filename = $base . "/static/js/perfect-scrollbar.js";
         $js .= file_get_contents($filename);
         $filename = $base . "/static/js/jquery.placeholder.js";
         $js .= file_get_contents($filename);
         $filename = $base . "/static/js/jquery.noty.packaged.min.js";
         $js .= file_get_contents($filename);
         $filename = $base . "/static/js/script.js";
         $js .= file_get_contents($filename);
         $js = JSMin::minify($js);
         file_put_contents($jsfilename, $js);
     }
     $cssfilename = $base . "/static/cache/final.css";
     if (!file_exists($cssfilename)) {
         $filename = $base . "/static/css/style.css";
         $css = file_get_contents($filename);
         $filename = $base . "/static/css/perfect-scrollbar.css";
         $css .= file_get_contents($filename);
         $minify = new CSSmin();
         $css = $minify->run($css, true);
         file_put_contents($cssfilename, $css);
     }
     return parent::beforeAction($action);
 }
开发者ID:aliazizi,项目名称:CShop,代码行数:34,代码来源:Controller.php

示例15: getJsContents

 /**
  * override method: get content of css files
  */
 function getJsContents($files, $isCompressed = true, $isYUI = false)
 {
     $contents = "/**ICE-ENGINE-JS**/";
     foreach ($files as $file) {
         $subpath = str_replace('/', DS, $file);
         $fullpath = JPATH_ROOT . DS . $subpath;
         //	$basepath = preg_replace( '/^\//', '', dirname($files2[$key]) );
         $contentFile = '';
         if (preg_match('/\\.php/', $file)) {
             $contentFile = @file_get_contents(JURI::base() . str_replace("&amp;", "&", $file));
         } else {
             if (file_exists($fullpath)) {
                 // get Content Of File;
                 $contentFile = @file_get_contents($fullpath);
             }
         }
         if ($contentFile) {
             $contents .= "/** '.{$subpath}.' **/\t";
             $contents .= $contentFile;
         }
     }
     if ($isCompressed) {
         if ($isYUI) {
             $app =& JFactory::getApplication();
             Minify_YUICompressor::$jarFile = dirname(__FILE__) . DS . 'Minify' . DS . 'yuicompressor-2.4.6.jar';
             Minify_YUICompressor::$tempDir = $app->getCfg("tmp_path");
             $contents = Minify_YUICompressor::minifyJs($contents, array('nomunge' => true, 'line-break' => 1000));
         } else {
             $contents = JSMin::minify($contents);
         }
     }
     return $contents;
 }
开发者ID:optimosolution,项目名称:marhk,代码行数:36,代码来源:minify.php


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