Example #1
0
 public function getMinifiedJavascript($filename)
 {
     //using google's closure compiler api
     $closure_compiler = new PhpClosure();
     $this->javascript = $closure_compiler->add($filename)->advancedMode()->useClosureLibrary()->hideDebugInfo()->write();
     // $filename = "../lib/jquery/jquery_closure_advance.js";
     // $this->javascript = file_get_contents($filename);
     //read variable declaration inside code
     $this->readAllFunctions();
     //set global variables
     $this->setGlobalVariables();
     //process literal and replace them by array position
     $this->processStringLiterals();
     //redefine function declaration replace function(){content} -> z("");
     $this->redefineFunctionDeclaration();
     // echo strlen($this->getJavascriptWithScope());
     return $this->getJavascriptWithScope();
 }
Example #2
0
 function generateJSFile($name, $list)
 {
     $url_default = base_url() . 'min/?b=scripts&f=';
     $url_list = array();
     $url = $url_default;
     foreach ($list as $file) {
         $url_list[] = 'scripts/' . $file . '.js';
     }
     if ($url != $url_default) {
         $url_list[] = trim($url, ',');
     }
     $content = '';
     foreach ($url_list as $url) {
         $content .= @file_get_contents($url) . "\n\n";
     }
     $content = str_replace(";\n;", "; \n", $content);
     if ($this->useClosure) {
         date_default_timezone_set('America/Los_Angeles');
         require_once APPPATH . 'models/libs/google-closure/php-closure.php';
         $c = new PhpClosure();
         $content = $c->setSourceCode($content)->simpleMode()->quiet()->write();
     }
     @file_put_contents("public/link/{$name}-min.js", $content);
     $this->addJSFile("{$name}-min");
 }
Example #3
0
    }
    // convert codes to binary string
    $dictionary_count = 256;
    $bits = 8;
    // ceil(log($dictionary_count, 2))
    $return = "";
    $rest = 0;
    $rest_length = 0;
    foreach ($codes as $code) {
        $rest = ($rest << $bits) + $code;
        $rest_length += $bits;
        $dictionary_count++;
        if ($dictionary_count >> $bits) {
            $bits++;
        }
        while ($rest_length > 7) {
            $rest_length -= 8;
            $return .= chr($rest >> $rest_length);
            $rest &= (1 << $rest_length) - 1;
        }
    }
    return $return . ($rest_length ? chr($rest << 8 - $rest_length) : "");
}
//
// Now my stuff
//
$c = new PhpClosure();
if (!file_exists(sys_get_temp_dir() . "/js-cache/")) {
    @mkdir(sys_get_temp_dir() . "/js-cache/");
}
$c->add("../ajax-node.js")->add("QUnit.zag.js")->add("QUnit.tests.js")->godMode(false)->advancedMode()->cacheDir(sys_get_temp_dir() . "/js-cache/")->write();
<?php

include "../php-closure.php";
$c = new PhpClosure();
$c->add("js/animation.js")->add("js/color.js")->advancedMode()->useClosureLibrary()->cacheDir("/tmp/js-cache/")->write();
Example #5
0
<?php

define('LIB_DIR', getcwd() . 'lib/');
include LIB_DIR . 'third-party/php-closure.php';
$c = new PhpClosure();
$c->add('my-app.js')->addDir('/js/')->add('popup.js')->add('popup.soy')->advancedMode()->cacheDir('/tmp/js-cache/')->localCompile()->write();
Example #6
0
 * @author      Emilien MOREL <*****@*****.**>
 * @link        http://www.website-php.com
 * @copyright   WebSite-PHP.com 12/05/2015
 * @version     1.2.13
 * @access      public
 * @since       1.0.19
 */
include "../config/config.inc.php";
include_once "utils_session.inc.php";
@session_set_cookie_params(0, "/", $_SERVER['SERVER_NAME'], false, true);
@session_name(formalize_to_variable(SITE_NAME));
@session_start();
$_GET['files'] = str_replace("|", "/", $_GET['files']);
if ($_GET['type'] == "js") {
    include "php-closure.php";
    $c = new PhpClosure();
    $nb_file = 0;
    $array_files = explode(',', $_GET['files']);
    for ($i = 0; $i < sizeof($array_files); $i++) {
        $file = "../js/" . $array_files[$i];
        $file2 = "../../" . $array_files[$i];
        if (file_exists($file) && is_file($file)) {
            $c->add($file);
            $nb_file++;
        } else {
            if (file_exists($file2) && is_file($file2)) {
                $c->add($file2);
                $nb_file++;
            } else {
                if (is_file($file)) {
                    echo "alert('Unable to load js file: " . $file . "');\n";
Example #7
0
<?php

include "../php-closure.php";
$c = new PhpClosure();
$c->add("js/animation.js")->add("js/color.js")->advancedMode()->useClosureLibrary()->useCodeUrl("http://yourhost.com/php-closure/examples/")->cacheDir("/tmp/js-cache/")->write();