• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP JavaScriptPacker类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: concatListAndPack

 /**
  * Perform actual compression
  * @param $src
  * @param $out
  * @param $mode
  * @return bool
  */
 function concatListAndPack($src, $out, $mode)
 {
     if (!is_file($src) || !is_readable($src)) {
         return false;
     }
     // Concat List into one big string
     $jscode = '';
     $handle = @fopen($src, 'r');
     if ($handle) {
         while (!feof($handle)) {
             $jsline = fgets($handle, 4096);
             if (rtrim($jsline, "\n") != "") {
                 $code = file_get_contents(AJXP_INSTALL_PATH . "/" . CLIENT_RESOURCES_FOLDER . "/" . rtrim($jsline, "\n\r"));
                 if ($code) {
                     $jscode .= $code;
                 }
             }
         }
         fclose($handle);
     }
     // Pack and write to file
     require_once "packer/class.JavaScriptPacker.php";
     $packer = new JavaScriptPacker($jscode, $mode, true, false);
     $packed = $packer->pack();
     if ($mode == "None") {
         // css case, hack for I.E.
         $packed = str_replace("solid#", "solid #", $packed);
     }
     @file_put_contents($out, $packed);
     return true;
 }
开发者ID:crodriguezn,项目名称:administrator-files,代码行数:38,代码来源:class.AJXP_JSPacker.php


示例2: pack

 public function pack($file)
 {
     $file = realpath($file);
     $home = dirname(__FILE__);
     $jar = realpath("{$home}/compiler.jar");
     $java = "java";
     exec("{$java} -version", &$output, &$result);
     if ($result != 0) {
         throw new BuildException("Java not found.");
     }
     // first we pack the file using DOJO shrinksafe
     $cmd = "{$java} -jar \"{$jar}\" --js=\"{$file}\" --js_output_file=\"{$file}.tmp\"";
     exec($cmd, &$output, &$result);
     if ($result != 0) {
         throw new BuildException("Java error.");
     }
     unlink($file);
     rename("{$file}.tmp", $file);
     // after DOJO, we use the Packer to tighten it up.
     $script = file_get_contents($file);
     $packer = new JavaScriptPacker($script, 62, true, false);
     $packed = $packer->pack();
     file_put_contents($file, $packed);
     $this->log("{$file} packed.", Project::MSG_INFO);
 }
开发者ID:superchangme,项目名称:jsplugin,代码行数:25,代码来源:PackerTask.php


示例3: filterDump

 public function filterDump(AssetInterface $asset)
 {
     $script = $asset->getContent();
     $packer = new \JavaScriptPacker($script, $this->_encoding, $this->_fastDecode, $this->_specialChars);
     $script = $packer->pack();
     $asset->setContent(str_replace(";;", ";", trim($script) . ";"));
 }
开发者ID:icedream,项目名称:javascriptpackerbundle,代码行数:7,代码来源:JavaScriptPackerFilter.php


示例4: packedScriptSrc

 /**
  * Combines, minifies and caches internal js files
  *
  * @param $files an array of internal js filenames. should be in modules/jQuery - EX: 	array('soundmanager2.js', 'jquery.omniplayer.js')
  * @param $useCache the default is to use a cached version, but for testing changes you might want to set to false
  */
 public function packedScriptSrc($files, $useCache = true)
 {
     $hash = md5(join(',', $files));
     $fileName = $hash . '.min.js';
     $dir = $this->installPath . '/js/';
     $scriptDir = '/accelsite/js/';
     $metaKey = 'accel_js_cached_packed_' . $hash;
     $externalPath = $scriptDir . $fileName;
     if ($useCache) {
         if ($cachedSrc = SiteInfo::findThis()->getMeta($metaKey, 0)) {
             if (file_exists($dir . $fileName)) {
                 return $cachedSrc;
             }
         }
     }
     foreach ($files as $src) {
         $script .= file_get_contents($this->includePath . '/modules/jQuery/' . $src) . ";";
     }
     $packer = new JavaScriptPacker($script, 'Normal', true, false);
     if (!file_exists($dir)) {
         mkdir($dir);
     }
     file_put_contents($dir . $fileName, $packer->pack() . "/*  cached:  " . date('r') . " */");
     SiteInfo::findThis()->setMeta($metaKey, $externalPath);
     return $externalPath;
 }
开发者ID:netacceleration,项目名称:accelpress,代码行数:32,代码来源:AccelJS.php


示例5: allowed_components

 function allowed_components()
 {
     $sOutput = '';
     $bSendPack = $this->config->item("send_pack");
     $sFileProd = $this->config->item("file_prod");
     $sFileDebug = $this->config->item("file_debug");
     $aFiels = get_filenames($sFileDebug);
     foreach ($aFiels as $sFile) {
         $aFileData = pathinfo($sFile);
         if (isset($aFileData["extension"]) && $aFileData["extension"] != "js") {
             continue;
         }
         if ($bSendPack) {
             $script = file_get_contents($sFileDebug . $sFile);
             $filemtime = @filemtime($sFileDebug . $sFile);
             $filemtimeCache = @filemtime($sFileProd . $sFile);
             $t1 = microtime(true);
             if (!$filemtimeCache || $filemtime > $filemtimeCache) {
                 $packer = new JavaScriptPacker($script, 'Normal', true, false);
                 $packed = $packer->pack();
                 file_put_contents($sFileProd . $sFile, $packed);
             }
             $t2 = microtime(true);
             $time = sprintf('%.4f', $t2 - $t1);
             $sOutput .= '/* Script ' . $sFile . ' packed in ' . $time . " s. */\n";
             $sOutput .= read_file($sFileProd . $sFile) . "\n\n";
         } else {
             $sOutput .= read_file($sFileDebug . $sFile) . "\n\n";
         }
     }
     header("Content-type: application/javascript");
     echo $sOutput;
     die;
 }
开发者ID:bardascat,项目名称:blogify,代码行数:34,代码来源:provider.php


示例6: pack_cQuery

function pack_cQuery($chemin) {
	$flux = spip_file_get_contents($chemin);
	$flux = str_replace('jQuery', 'cQuery', $flux);

	// On ne compacte PAS deux fois (c'est inutile et en plus ca bugge)
	if (!strlen($flux)
	// mode debug des crayons
	OR _request('debug_crayons')
	// le vieil auto_compress_js
	OR ($GLOBALS['meta']['auto_compress_js'] == 'oui'
	  AND @file_exists(_DIR_RESTREINT.'inc/compacte_js.php'))
	// ou l'espace prive
	OR !function_exists('test_espace_prive')
	OR test_espace_prive())
		return $flux;

	include_spip('lib/JavaScriptPacker/class.JavaScriptPacker');
	$packer = new JavaScriptPacker($flux, 0, true, false);

	// en cas d'echec (?) renvoyer l'original
	if (strlen($t = $packer->pack()))
		return $t;

	// erreur
	spip_log('erreur de pack_js');
	return $flux;
}
开发者ID:rhertzog,项目名称:lcs,代码行数:27,代码来源:crayons.js_fonctions.php


示例7: tocpjs

 public function tocpjs($path)
 {
     if (!is_dir($this->devpath . $path)) {
         if (strpos(strtolower($path), '.js') == strlen($path) - 3) {
             if (file_exists($this->propath . $path) && filemtime($this->devpath . $path) < filemtime($this->propath . $path)) {
                 return;
             }
             File::creat_dir_with_filepath($this->propath . $path);
             $buffer = file_get_contents($this->devpath . $path);
             //如果传入的是JS文件则压缩
             if (!$this->needcomp) {
                 file_put_contents($this->propath . $path, $buffer);
             } else {
                 $packer = new JavaScriptPacker($buffer, 'Normal', true, false);
                 file_put_contents($this->propath . $path, $packer->pack());
             }
         } else {
             @copy($this->devpath . $path, $this->propath . $path);
         }
         return;
     }
     //如果传入的参数是目录
     $handle = File::scandir($this->devpath . $path);
     foreach ($handle as $file) {
         if ($file != '.' && $file != '..') {
             $dir = $path . '/' . $file;
             //当前文件$dir为文件目录+文件
             $this->tocpjs($dir);
         }
     }
     return;
 }
开发者ID:codingoneapp,项目名称:codingone,代码行数:32,代码来源:compress.php


示例8: 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


示例9: smarty_function_script

/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */
function smarty_function_script($params, &$smarty)
{
    static $scripts = array();
    static $packer_loaded = false;
    /*if (!empty($params['include'])) {
    		return implode("\n", $scripts);
    	}*/
    if (!isset($scripts[$params['src']])) {
        $path = Registry::get('config.current_path');
        if (Registry::get('config.tweaks.js_compression') == true && strpos($params['src'], 'lib/') === false) {
            if (!file_exists(DIR_CACHE . $params['src'])) {
                if ($packer_loaded == false) {
                    include_once DIR_LIB . 'packer/class.JavaScriptPacker.php';
                    $packer_loaded = true;
                }
                fn_mkdir(dirname(DIR_CACHE . $params['src']));
                $packer = new JavaScriptPacker(fn_get_contents(DIR_ROOT . '/' . $params['src']));
                fn_put_contents(DIR_CACHE . $params['src'], $packer->pack());
            }
            $path = Registry::get('config.cache_path');
        }
        $scripts[$params['src']] = '<script type="text/javascript" src="' . $path . '/' . $params['src'] . '"></script>';
        // If output is captured, don't print script tag in the buffer, it will be printed directly to the screen
        if (!empty($smarty->_in_capture)) {
            $buff = array_pop($smarty->_in_capture);
            $smarty->_in_capture[] = $buff;
            $smarty->_scripts[$buff][] = $scripts[$params['src']];
            return '';
        }
        return $scripts[$params['src']];
    }
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:37,代码来源:function.script.php


示例10: _js_compress

 private function _js_compress($content)
 {
     App::import('vendor', 'inc/jspacker');
     $js = new JavaScriptPacker($content, $this->_js_encode, true, false);
     $this->setEncode(0);
     return $js->pack();
 }
开发者ID:tilitala,项目名称:nForum,代码行数:7,代码来源:packer.php


示例11: packJavascript

function packJavascript($version)
{
    $jsDir = 'resources/htdocs/js';
    $packFile = "{$jsDir}/packed-{$version}.js";
    $unpackFile = "{$jsDir}/unpacked-{$version}.js";
    $licenses = '';
    $allScript = '';
    $preloadFiles = array('jquery.js', 'sockso.js');
    $postloadFiles = array('init.js');
    foreach ($preloadFiles as $preloadFile) {
        $allScript .= file_get_contents("{$jsDir}/{$preloadFile}");
        $licenses .= extractLicenses($allScript);
    }
    $d = opendir($jsDir);
    $dirlist = array();
    // then read in all javascript files and pack them up
    while ($file = readdir($d)) {
        $dirlist[] = $file;
    }
    sort($dirlist);
    foreach ($dirlist as $key => $file) {
        $path = "{$jsDir}/{$file}";
        // remove old pack files
        if (preg_match('/packed-/', $file)) {
            unlink($path);
        } elseif (!in_array($file, array_merge($preloadFiles, $postloadFiles)) && substr($file, -2) == 'js' && !preg_match('/locale.\\w+/', $file)) {
            echo "Include: {$path}\n";
            $script = file_get_contents($path);
            $licenses .= extractLicenses($script);
            $allScript .= $script;
        }
    }
    foreach ($postloadFiles as $file) {
        $allScript .= file_get_contents("{$jsDir}/{$file}");
        $licenses .= extractLicenses($allScript);
    }
    // write unpacked javascript
    $f = fopen($unpackFile, 'w');
    fwrite($f, $allScript);
    fclose($f);
    // write packed javascript
    $f = fopen($packFile, 'w');
    switch (PACK_TYPE) {
        case PACK_PACKER:
            include 'lib/php/JavaScriptPacker.class.php';
            $packer = new JavaScriptPacker($allScript, 'Normal', true, false);
            fwrite($f, $licenses . $packer->pack());
            break;
        case PACK_YUI:
            fwrite($f, $allScript);
            system(sprintf('java -jar lib/dev/yuicompressor-2.4.2.jar --type js -o "%s" "%s"', $packFile, $unpackFile));
            break;
        case PACK_NONE:
            fwrite($f, $allScript);
            // not packed
            break;
    }
    fclose($f);
}
开发者ID:nguillaumin,项目名称:sockso,代码行数:59,代码来源:pack-resources.php


示例12: combine_getArchive

function combine_getArchive($aFiles, $fileType)
{
    $sDocRoot = $_SERVER['DOCUMENT_ROOT'];
    $iETag = (int) $_GET['version'];
    $sLastModified = gmdate('D, d M Y H:i:s', $iETag) . ' GMT';
    // see if the user has an updated copy in browser cache
    if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $sLastModified || isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $iETag) {
        header("{$_SERVER['SERVER_PROTOCOL']} 304 Not Modified");
        exit;
    }
    // create a directory for storing current and archive versions
    if (CREATE_ARCHIVE && !is_dir("{$sDocRoot}/" . ARCHIVE_FOLDER)) {
        mkdir("{$sDocRoot}/" . ARCHIVE_FOLDER);
    }
    // get code from archive folder if it exists, otherwise grab latest files, merge and save in archive folder
    if (CREATE_ARCHIVE && file_exists("{$sDocRoot}/" . ARCHIVE_FOLDER . "/{$iETag}.cache")) {
        $sCode = file_get_contents("{$sDocRoot}/" . ARCHIVE_FOLDER . "/{$iETag}.cache");
    } else {
        // get and merge code
        $sCode = '';
        $aLastModifieds = array();
        foreach ($aFiles as $sFile) {
            $aLastModifieds[] = filemtime("{$sDocRoot}/{$sFile}");
            $sCode .= file_get_contents("{$sDocRoot}/{$sFile}") . "\n";
        }
        // sort dates, newest first
        rsort($aLastModifieds);
        if (CREATE_ARCHIVE) {
            if ($iETag == $aLastModifieds[0]) {
                // check for valid etag, we don't want invalid requests to fill up archive folder
                $oFile = fopen("{$sDocRoot}/" . ARCHIVE_FOLDER . "/{$iETag}.cache", 'w');
                if (flock($oFile, LOCK_EX)) {
                    fwrite($oFile, $sCode);
                    flock($oFile, LOCK_UN);
                }
                fclose($oFile);
            } else {
                // archive file no longer exists or invalid etag specified
                header("{$_SERVER['SERVER_PROTOCOL']} 404 Not Found");
                exit;
            }
        }
    }
    // send HTTP headers to ensure aggressive caching
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + CACHE_LENGTH) . ' GMT');
    // 1 year from now
    header('Content-Type: ' . $fileType);
    header('Content-Length: ' . strlen($sCode));
    header("Last-Modified: {$sLastModified}");
    header("ETag: {$iETag}");
    header('Cache-Control: max-age=' . CACHE_LENGTH);
    // output merged code
    if (PACK == 1) {
        $packer = new JavaScriptPacker($sCode);
        $sCode = $packer->pack();
    }
    echo $sCode;
}
开发者ID:Imagenomad,项目名称:Unsupported,代码行数:58,代码来源:merge.php


示例13: _compression_js

 protected function _compression_js($script)
 {
     $this->load->library('web_apps/JavaScriptPacker');
     //$packer = new JavaScriptPacker($script, 'Normal', true, false);
     //$packer = new JavaScriptPacker($script, 62, false, true);
     $packer = new JavaScriptPacker($script, 62, false, true);
     $packed = $packer->pack();
     return $packed;
 }
开发者ID:119155012,项目名称:kals,代码行数:9,代码来源:admin_apps_controller.php


示例14: compress

 public function compress($script_in)
 {
     try {
         $packer = new JavaScriptPacker($script_in);
     } catch (Exception $e) {
         throw new PreprocessFailureException(array('processor' => 'JavaScriptPacker'));
     }
     return $packer->pack();
 }
开发者ID:ronnyvv,项目名称:ResourcesController,代码行数:9,代码来源:JsProcessorComponent.php


示例15: compress_javascript

function compress_javascript($js)
{
    if (!class_exists('JavaScriptPacker')) {
        if ($JavaScriptPackerDir = RD::$Self->Lib('javascriptpacker')) {
            require_once $JavaScriptPackerDir . DIR_SEP . 'class.JavaScriptPacker.php';
        } else {
            throw new RDE('I need JavaScriptPacker!!! (says compress_javascript function)');
        }
    }
    $Packer = new JavaScriptPacker($js);
    return $Packer->pack();
}
开发者ID:Getty,项目名称:historical-php-rapidev,代码行数:12,代码来源:compress_javascript.php


示例16: compile_files

 private function compile_files()
 {
     foreach ($this->scripts as $value) {
         $script = file_get_contents($value);
         if ($this->compress_file) {
             $packer = new JavaScriptPacker($script, 'None', false, false);
             $script = $packer->pack();
         }
         $scripts[] = $script;
     }
     return $scripts;
 }
开发者ID:shaunfreeman,项目名称:Uthando-CMS,代码行数:12,代码来源:JsLoader.php


示例17: stimulate

 public function stimulate(&$hash)
 {
     $io = LINB::SC('IO');
     $strArr = array();
     foreach ($this->ARR as $v) {
         array_push($strArr, $io->getString(self::PATH . $v . '.js'));
     }
     $str = implode(';', $strArr);
     $packer = new JavaScriptPacker($str, 'None', false, false);
     $packed = $packer->pack();
     $io->setString(self::PACKED, $packed);
     unset($io);
     unset($packer);
 }
开发者ID:notchent,项目名称:linb,代码行数:14,代码来源:PackJsLinb.php


示例18: __construct

	public function __construct($node){
		$this->node=$node;
		
		if(!is_dir($node->ini['front']['cache_dir'])&& !mkdir($node->ini['front']['cache_dir'])) die('<h1>No cache directory available!</h1> <p>Please create '.$node->ini['front']['cache_dir'].' with mode 0777.</p>');
		$min_file=$node->ini['front']['cache_dir'].$node->ini['front']['js_min'];
		$re_minify=false;
		if(!file_exists($min_file)){
			if(!$node->ini['front']['debug_js']) $re_minify=true;
			$min_file_mtime=0;
		}else{
			$min_file_mtime=filemtime($min_file);
		}
		if(isset($node->ini['front']['js']) && is_array($node->ini['front']['js'])){
			foreach($node->ini['front']['js'] as $file){
				if(substr($file,0,2)!=='//' && !$node->ini['front']['debug_js']){
					if(file_exists($file) && filemtime($file) > $min_file_mtime) 
						$re_minify=true;
				}else $this->js[]=$file;
					
			}
		}else{ $re_minify=true; }
		//Reminify css if its been updated
		if($re_minify){ 
			# Include minify library
			require $node->fs_path.'lib/jsmin.php';
			$script = "";
			if(isset($node->ini['front']['js']) && is_array($node->ini['front']['js'])){
				foreach($node->ini['front']['js'] as $file){
					if(substr($file,0,2)!=='//') $script .= file_get_contents($file);
				}
			}
		
			$packer = new JavaScriptPacker($script, 'Normal', true, false);
			$packed = $packer->pack();
			//Save/Update minified version
			if(file_exists($min_file)) unlink($min_file);
			file_put_contents($min_file, $packed);
		}
		if(!$node->ini['front']['debug_js']) $this->js[]=$min_file;
		
		$html='';
		if(isset($node->query['page']))
			$toRoot=str_repeat('../',count(explode('/',$node->query['page']))-1);
		else $toRoot='';
		foreach($this->js as $file){
			$html.='<script src="'.(substr($file,0,2)!=='//' ? $toRoot : '').$file.'"></script>'."\n";
		}
		$node->page['headerHTML'][]=$html;
	}
开发者ID:numtel,项目名称:salamander,代码行数:49,代码来源:js.php


示例19: compact_files

function compact_files($header, $srcdir, $files, $destination_packed, $destination)
{
    $t1 = microtime(true);
    $content = '';
    foreach ($files as $src) {
        $src = "{$srcdir}/{$src}";
        $content .= file_get_contents($src);
    }
    $packer = new JavaScriptPacker($content, 'Normal', true, false);
    $packed = $header . $packer->pack();
    $t2 = microtime(true);
    $time = sprintf('%.4f', $t2 - $t1);
    echo 'script ', $destination_packed, ' packed in ', $out, ', in ', $time, ' s.', "\n";
    file_put_contents($destination_packed, $packed);
    file_put_contents($destination, $header . $content);
}
开发者ID:Kraiany,项目名称:kraiany_site_docker,代码行数:16,代码来源:make-js.php


示例20: minifyJS

 function minifyJS()
 {
     require ROOT . 'lib/MinifyJS/class.JavaScriptPacker.php';
     $js = array_diff(scandir(ROOT . self::JS_SRC_PATH, 1), array('.', '..'));
     if (empty($js)) {
         return;
     }
     foreach ($js as $file_name) {
         $js_full_path = ROOT . self::JS_SRC_PATH . '/' . $file_name;
         $script = file_get_contents($js_full_path);
         unlink($js_full_path);
         $packer = new JavaScriptPacker($script, 'Normal', true, false);
         $packed = $packer->pack();
         file_put_contents(ROOT . self::JS_PATH . '/' . $file_name, $packed);
     }
 }
开发者ID:PhantomOfTheOpera,项目名称:coolroom_code,代码行数:16,代码来源:updater.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP JavascriptLoadManager类代码示例发布时间:2022-05-23
下一篇:
PHP JavaScriptHelper类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap