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

PHP JSMinPlus类代码示例

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

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



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

示例1: getSetup

    public static function getSetup()
    {
        global $wgUser, $IP, $wgMemc;
        $isHHM = wikihowAds::isHHM();
        $isABTest = wikihowAds::isABTestArticle();
        $cachekey = wfMemcKey('ads_setup', intval($isHHM), intval($isABTest), WH_SITEREV);
        //$html = $wgMemc->get($cachekey);
        $html = null;
        if ($html === null) {
            $js = wfMsg('Wikihowads_setup', $isHHM, intVal($isABTest));
            require_once "{$IP}/extensions/min/lib/JSMinPlus.php";
            $adsClass = file_get_contents("{$IP}/extensions/wikihow/wikihowAds/wikihowAds.js");
            $min = JSMinPlus::minify($adsClass . $js);
            $html = <<<EOHTML
<!-- MediaWiki:wikihowads_setup -->
<script type='text/javascript'>
<!--
{$min}
//-->
</script>
EOHTML;
            $wgMemc->set($cachekey, $html);
        }
        return $html;
    }
开发者ID:ErdemA,项目名称:wikihow,代码行数:25,代码来源:wikihowAds.class.php


示例2: summarize_registry

/**
 * Summarize the file registry in a way like
 * [ 'ext1' => 'contents', 'ext2' => 'contents' ]
 *
 * @return array
 */
function summarize_registry()
{
    $summasummarum = array();
    $keys = array_keys($_SESSION['files_registry']);
    foreach ($keys as $filename) {
        $summarized = "";
        $last_dot_pos = strrpos($filename, ".");
        $ext = strtolower(substr($filename, $last_dot_pos + 1, strlen($filename) - $last_dot_pos - 1));
        if (!$_SESSION['files_registry'][$filename]['good']) {
            unset($_SESSION['files_registry'][$filename]);
            echo sprintf("[Deleted] %s\n-- %s\n\n", date('H:i:s'), $filename);
            continue;
        }
        $summarized .= trim(file_get_contents($filename));
        if (!isset($summasummarum[$ext])) {
            $summasummarum[$ext] = "";
        }
        if ($ext == 'css') {
            $summarized = Minify_CSS::minify(file_get_contents($filename));
        } else {
            if ($ext == 'js') {
                $summarized = JSMinPlus::minify(file_get_contents($filename));
            } else {
                $summarized = trim(file_get_contents($filename));
            }
        }
        $summasummarum[$ext] .= $summarized;
    }
    return $summasummarum;
}
开发者ID:allenlinatoc,项目名称:assetmon,代码行数:36,代码来源:registry.functions.php


示例3: test_JSMinPlus

function test_JSMinPlus()
{
    global $thisDir;
    $src = file_get_contents($thisDir . '/_test_files/js/condcomm.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/condcomm.min_plus.js');
    $minOutput = JSMinPlus::minify($src);
    $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Conditional Comments');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
    }
    return;
    $src = file_get_contents($thisDir . '/_test_files/js/before.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/before.min_plus.js');
    $minOutput = JSMinPlus::minify($src);
    $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Overall');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
    }
    $src = file_get_contents($thisDir . '/_test_files/js/issue74.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/issue74.min_plus.js');
    $minOutput = JSMinPlus::minify($src);
    $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Quotes in RegExp literals (Issue 74)');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n";
    }
}
开发者ID:awwthentic1234,项目名称:hey,代码行数:32,代码来源:test_JSMinPlus.php


示例4: js

    /**
     * Minify JS code.
     *
     * @param string $content
     * @return string minified JS code
     */
    public static function js($content)
    {
        global $CFG;
        require_once "{$CFG->libdir}/minify/lib/JSMinPlus.php";
        try {
            ob_start();
            // JSMinPlus just echos errors, weird...
            $compressed = JSMinPlus::minify($content);
            if ($compressed !== false) {
                ob_end_clean();
                return $compressed;
            }
            $error = ob_get_clean();
        } catch (Exception $e) {
            ob_end_clean();
            $error = $e->getMessage();
        }
        $return = <<<EOD

try {console.log('Error: Minimisation of JavaScript failed!');} catch (e) {}

// Error: {$error}
// Problem detected during JavaScript minimisation, please review the following code
// =================================================================================


EOD;
        return $return . $content;
    }
开发者ID:evltuma,项目名称:moodle,代码行数:35,代码来源:minify.php


示例5: postprocess

 public function postprocess(&$path, &$content)
 {
     if (!class_exists('JSMinPlus')) {
         $dir = Templates_HTML_Postprocess::option('minify_php_dir');
         require_once $dir . 'JSMin/JSMin.php';
     }
     $content = JSMinPlus::minify($content);
 }
开发者ID:techart,项目名称:tao,代码行数:8,代码来源:Postprocess.php


示例6: doProcessFile

 public function doProcessFile($file, $replace = false)
 {
     $optimizedContent = JSMinPlus::minify(file_get_contents($file));
     if ($replace) {
         return parent::replaceFile($file, $optimizedContent);
     } else {
         return $optimizedContent;
     }
 }
开发者ID:n1k0,项目名称:npAssetsOptimizerPlugin,代码行数:9,代码来源:npDriverJSMinPlus.class.php


示例7: apply

 /**
  */
 public function apply($in, $params = [])
 {
     require_php_lib('jsminplus');
     if (!class_exists('\\JSMinPlus')) {
         throw new Exception('Assets: class \\JSMinPlus not found');
         return $in;
     }
     return \JSMinPlus::minify($in);
 }
开发者ID:yfix,项目名称:yf,代码行数:11,代码来源:yf_assets_filter_jsminplus.class.php


示例8: compress

 public function compress($string)
 {
     // Compress the js-code
     $jsMinPhp = JPATH_SITE . '/components/com_scriptmerge/lib/jsminplus.php';
     if (file_exists($jsMinPhp)) {
         include_once $jsMinPhp;
         if (class_exists('JSMinPlus')) {
             $string = JSMinPlus::minify($string);
         }
     }
     return $string;
 }
开发者ID:JeroenJ3,项目名称:pkg_scriptmerge,代码行数:12,代码来源:jsminplus.php


示例9: postprocess

 public function postprocess($path, $data, $content = null)
 {
     if (!class_exists('JSMinPlus')) {
         $dir = Templates_HTML_Assets_Postprocess_Minify::option('minify_php_dir');
         require_once $dir . 'JSMinPlus/JSMinPlus.php';
     }
     if ($this->filter($path, $data)) {
         if (empty($content)) {
             list($content, $path) = $this->load($path);
         }
         if (!empty($content)) {
             $content = JSMinPlus::minify($content);
         }
     }
     return array($path, $content);
 }
开发者ID:techart,项目名称:tao,代码行数:16,代码来源:Minify.php


示例10: test_JSMinPlus

function test_JSMinPlus()
{
    global $thisDir;
    $src = file_get_contents($thisDir . '/_test_files/js/condcomm.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/condcomm.min_plus.js');
    $minOutput = JSMinPlus::minify($src);
    $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Conditional Comments');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . strlen($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . strlen($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . strlen($src) . " bytes\n\n{$src}\n\n\n";
    }
    return;
    $src = file_get_contents($thisDir . '/_test_files/js/before.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/before.min_plus.js');
    $minOutput = JSMinPlus::minify($src);
    $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Overall');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . strlen($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . strlen($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . strlen($src) . " bytes\n\n{$src}\n\n\n";
    }
    $src = file_get_contents($thisDir . '/_test_files/js/issue74.js');
    $minExpected = file_get_contents($thisDir . '/_test_files/js/issue74.min_plus.js');
    $minOutput = JSMinPlus::minify($src);
    $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Quotes in RegExp literals (Issue 74)');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " . strlen($minOutput) . " bytes\n\n{$minOutput}\n\n";
        echo "---Expected: " . strlen($minExpected) . " bytes\n\n{$minExpected}\n\n";
        echo "---Source: " . strlen($src) . " bytes\n\n{$src}\n\n\n";
        /*
                test_JSMin_exception('"Hello'
                                    ,'Unterminated String'
                                    ,'JSMin_UnterminatedStringException'
                                    ,"Unterminated String: '\"Hello'");
                test_JSMin_exception("return /regexp\n}"
                                    ,'Unterminated RegExp'
                                    ,'JSMin_UnterminatedRegExpException'
                                    ,"Unterminated RegExp: '/regexp\n'");
                test_JSMin_exception("/* Comment "
                                    ,'Unterminated Comment'
                                    ,'JSMin_UnterminatedCommentException'
                                    ,"Unterminated Comment: '/* Comment '");
                //*/
    }
}
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:46,代码来源:test_JSMinPlus.php


示例11: compile

 public function compile()
 {
     $doc = JFactory::getDocument();
     $headers = $doc->getHeadData();
     $javascripts = JArrayHelper::getValue($headers, 'scripts');
     $dest = JPath::clean($this->paths->get('js.compressed'));
     $compile = $this->params->get('minify_js', 1);
     $changed = (bool) $this->isJsUpdated();
     JLog::add('Javascript cache changed: ' . ((bool) $changed ? 'true' : 'false'), JLog::DEBUG, $this->logger);
     $force = (bool) ($compile == 2);
     $changed = (bool) ($compile == 1 && $changed);
     JLog::add('Force Javascript minification: ' . ((bool) $force ? 'true' : 'false'), JLog::DEBUG, $this->logger);
     JLog::add('Minify Javascript: ' . ((bool) $changed ? 'true' : 'false'), JLog::DEBUG, $this->logger);
     $uncompressed = '';
     foreach (array_keys($javascripts) as $script) {
         $url = new JUri($script);
         if (!$url->getScheme()) {
             $url = new JUri(JUri::base());
             $url->setPath($script);
         }
         $key = str_replace(JUri::base(), JPATH_ROOT . '/', (string) $url);
         if (array_search($key, $this->paths->get('js.uncompressed')) !== false) {
             unset($headers['scripts'][$script]);
             if (!JFile::exists($dest) || $changed || $force) {
                 JLog::add('Compressing: ' . $key . ' to ' . $dest, JLog::DEBUG, $this->logger);
                 $stream = new JStream();
                 $stream->open($key);
                 $response = $stream->read($stream->filesize());
                 $stream->close();
                 $uncompressed .= $response;
             }
         }
     }
     if ($uncompressed) {
         file_put_contents($dest, JSMinPlus::minify($uncompressed, $dest));
         $this->updateCache(self::CACHEKEY . '.files.js', $this->paths->get('js.uncompressed'));
     }
     // workaround. There needs to be at least one script.
     if (count($headers['scripts']) == 0) {
         $url = str_replace(JPATH_ROOT . '/', JUri::base(), $dest);
         $headers['scripts'][$url] = array('mime' => 'text/javascript', 'defer' => false, 'async' => false);
     }
     $doc->setHeadData($headers);
 }
开发者ID:Vartacom,项目名称:bootstrapbase,代码行数:44,代码来源:js.php


示例12: parse_string

 public function parse_string($template, $data = array(), $return = FALSE, $options = array())
 {
     if (!is_array($options)) {
         $options = array();
     }
     $options = array_merge($this->config, $options);
     $ci = $this->ci;
     $is_mx = false;
     if (!$return) {
         list($ci, $is_mx) = $this->detect_mx();
     }
     ob_start();
     $template = JSMinPlus::minify($template);
     $exception_message = ob_get_contents();
     ob_end_clean();
     if ($exception_message != '') {
         throw new Exception('JSMinPlus: ' . $exception_message);
     }
     return $this->output($template, $return, $ci, $is_mx);
 }
开发者ID:bhavesh561988,项目名称:starter-public-edition-4,代码行数:20,代码来源:Parser_jsmin.php


示例13: minify

 public function minify($js)
 {
     try {
         if ($this->conf->outputfilters->javascriptminifyalgorithm == "jsminplus") {
             $js = JSMinPlus::minify($js);
         } else {
             if ($this->conf->outputfilters->javascriptminifyalgorithm == "yuicompressor") {
                 Minify_YUICompressor::$tempDir = PIMCORE_TEMPORARY_DIRECTORY;
                 Minify_YUICompressor::$jarFile = PIMCORE_PATH . "/lib/Minify/yuicompressor-2.4.2.jar";
                 $js = Minify_YUICompressor::minifyJs($js);
             } else {
                 $js = JSMin::minify($js);
             }
         }
     } catch (Exception $e) {
         Logger::error("Unable to minify javascript");
         Logger::error($e);
     }
     return $js;
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:20,代码来源:JavascriptMinify.php


示例14: compress

 protected function compress($data, $config)
 {
     switch ($config['type']) {
         case 'jsmin':
             include_once Kohana::find_file('vendor', 'JSMin');
             return JSMin::minify($data);
         case 'jsminplus':
             include_once Kohana::find_file('vendor', 'jsminplus');
             return JSMinPlus::minify($data);
         case 'packer':
             include_once Kohana::find_file('vendor', 'JavaScriptPacker');
             $packer = new JavaScriptPacker($data, empty($config['level']) ? 'Normal' : $config['level']);
             return $packer->pack();
         case 'yuicompressor':
             $options = isset($config['options']) ? $config['options'] : '';
             return yuicompressor::compress($data, 'js', $options);
         default:
             throw new Kohana_User_Exception('Unknown Javascript Compression Type', 'Unknown type: ' . $config['type']);
     }
 }
开发者ID:evansd-archive,项目名称:kohana-module--assets,代码行数:20,代码来源:javascript.php


示例15: doExecute

 /**
  * doExecute
  *
  * @return  int
  */
 protected function doExecute()
 {
     $path = $this->getArgument(0);
     $package = $this->getOption('p');
     $folder = $this->console->get('asset.folder', 'asset');
     if ($package = PackageHelper::getPackage($package)) {
         $path = $package->getDir() . '/Resources/asset/' . $path;
     } else {
         $path = WINDWALKER_PUBLIC . '/' . trim($folder, '/') . '/' . $path;
     }
     if (is_file($path)) {
         $files = array(new \SplFileInfo($path));
     } elseif (is_dir($path)) {
         $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::FOLLOW_SYMLINKS));
     } else {
         throw new \InvalidArgumentException('No path');
     }
     /** @var \SplFileInfo $file */
     foreach ($files as $file) {
         $ext = File::getExtension($file->getPathname());
         if (StringHelper::endsWith($file->getBasename(), '.min.' . $ext)) {
             continue;
         }
         if ($ext == 'css') {
             $this->out('[<comment>Compressing</comment>] ' . $file);
             $data = \Minify_CSS_Compressor::process(file_get_contents($file));
             $data = str_replace("\n", ' ', $data);
         } elseif ($ext == 'js') {
             $this->out('[<comment>Compressing</comment>] ' . $file);
             $data = \JSMinPlus::minify(file_get_contents($file));
             $data = str_replace("\n", ';', $data);
         } else {
             continue;
         }
         $newName = $file->getPath() . '/' . File::stripExtension($file->getBasename()) . '.min.' . $ext;
         file_put_contents($newName, $data);
         $this->out('[<info>Compressed</info>] ' . $newName);
     }
 }
开发者ID:ventoviro,项目名称:phoenix,代码行数:44,代码来源:MinifyCommand.php


示例16: minify_javascript

 static function minify_javascript(&$root, $indent_string = ' ', $wrap_comment = true, $recursive = true)
 {
     include_once 'third party/jsminplus.php';
     $errors = array();
     foreach ($root->select('script:not-empty > "~text~"', false, $recursive, true) as $c) {
         try {
             $text = $c->text;
             while ($text) {
                 $text = trim($text);
                 if (substr($text, 0, 4) === '<!--') {
                     $text = substr($text, 5);
                     continue;
                 } elseif (strtolower(substr($text, 0, 9)) === '<![cdata[') {
                     $text = substr($text, 10);
                     continue;
                 }
                 if (($end = substr($text, -3)) && ($end === '-->' || $end === ']]>')) {
                     $text = substr($text, 0, -3);
                     continue;
                 }
                 break;
             }
             if (trim($text)) {
                 $text = JSMinPlus::minify($text);
                 if ($wrap_comment) {
                     $text = "<!--\n" . $text . "\n//-->";
                 }
                 if ($indent_string && ($wrap_comment || strpos($text, "\n") !== false)) {
                     $text = indent_text("\n" . $text, $c->indent(), $indent_string);
                 }
             }
             $c->text = $text;
         } catch (Exception $e) {
             $errors[] = array($e, $c->parent->dumpLocation());
         }
     }
     return $errors ? $errors : true;
 }
开发者ID:wangoviridans,项目名称:ganon,代码行数:38,代码来源:Formatter.php


示例17: executeGetMinified

 /**
  * Get a file's content, minified.
  * @param  string $path The file path.
  * @return string       The file's content, minified.
  */
 public function executeGetMinified($path)
 {
     $manager = $this->managers()->getManagerOf('file');
     if (!$manager->exists($path)) {
         throw new \RuntimeException('"' . $path . '" : no such file or directory', 404);
     }
     $out = $manager->read($path);
     if ($manager->extension($manager->filename($path)) != 'min' && false) {
         $ext = $manager->extension($path);
         switch ($ext) {
             case 'js':
                 $out = \JSMinPlus::minify($out);
                 break;
             case 'css':
                 $minifier = new \CssMin();
                 $out = $minifier->minify($out);
                 break;
             default:
                 throw new \RuntimeException('Cannot minify "' . $path . '" : unsupported file type', 406);
         }
     }
     $this->responseContent->setChannel(1, $out);
 }
开发者ID:CanaimaGNULinux,项目名称:Canaima-Tour,代码行数:28,代码来源:FileController.class.php


示例18: minify

	public static function minify($js, $filename='')
	{
		static $instance;

		// this is a singleton
		if(!$instance)
			$instance = new JSMinPlus();

		return $instance->min($js, $filename);
	}
开发者ID:ufwebadmin,项目名称:MIT-Mobile-Web,代码行数:10,代码来源:JSMinPlus.php


示例19: optimizeScriptCode

 /**
  * Optimize script code
  * @param string $data script code
  * @return string optimized script code
  */
 private function optimizeScriptCode($code)
 {
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'JSMinPlus.php';
     $minified = JSMinPlus::minify($code);
     return $minified === false ? $code : $minified;
 }
开发者ID:nilojan,项目名称:yii-cms,代码行数:11,代码来源:EClientScript.php


示例20: flush

 if (file_exists($minifiedPathname) && filemtime($minifiedPathname) > filemtime($pathname)) {
     // Is het cache bestand up2date?
     echo '  "' . $filename . '" (cached) ';
     flush();
     $minifiedSize = filesize($minifiedPathname);
     $fullSize = filesize($pathname);
 } else {
     // Het bestand moet (opnieuw) geminified worden
     echo "  Processing: \"" . $filename . "\"";
     flush();
     $script = file_get_contents($pathname);
     $fullSize = strlen($script);
     if ($type === 'css') {
         $minifiedScript = \CssMin::minify($script);
     } elseif ($type === 'javascript') {
         $minifiedScript = \JSMinPlus::minify($script);
     } else {
         $minifiedScript = ImageOptimizer::minify($script, $filename);
     }
     if ($minifiedScript === false) {
         // Is het minify proces mislukt?
         $minifiedScript = $script;
         // Gebruik dan het orginele bestand.
     }
     $minifiedSize = strlen($minifiedScript);
     mkdirs(dirname($minifiedPathname) . '/');
     if (file_put_contents($minifiedPathname, $minifiedScript) === false) {
         echo "\n  FAILED.\n";
         exit;
     }
 }
开发者ID:sledgehammer,项目名称:minify,代码行数:31,代码来源:minify_DocumentRoot.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP JSNConfigHelper类代码示例发布时间:2022-05-23
下一篇:
PHP JSMin类代码示例发布时间: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