Exemplo n.º 1
0
if (isset($FUNCTION_MAP) && is_array($FUNCTION_MAP)) {
    foreach ($FUNCTION_MAP as $key => $value) {
        $entry = $FUNCTION_MAP[$key]['class'];
        $cache_contents .= "\t'{$key}'\t:\tSUGAR.expressions.{$entry},";
    }
}
$cache_contents = substr($cache_contents, 0, -1);
$cache_contents .= "};\n";
$cache_contents .= <<<EOQ
/**
 * The function to object map that is used by the Parser
 * to parse expressions into objects.
 */
SUGAR.NumericConstants = {

EOQ;
if (isset(Parser::$NUMERIC_CONSTANTS) && is_array(Parser::$NUMERIC_CONSTANTS)) {
    foreach (Parser::$NUMERIC_CONSTANTS as $key => $value) {
        $cache_contents .= "\t'{$key}'\t:\t{$value},";
    }
}
$cache_contents = substr($cache_contents, 0, -1);
$cache_contents .= "};\n";
create_cache_directory("Expressions/functions_cache_debug.js");
sugar_file_put_contents(sugar_cached("Expressions/functions_cache_debug.js"), $cache_contents);
require_once "jssource/minify_utils.php";
$minifyUtils = new SugarMinifyUtils();
$minifyUtils->CompressFiles(sugar_cached('Expressions/functions_cache_debug.js'), sugar_cached('Expressions/functions_cache.js'));
if (!$silent) {
    echo "complete.";
}
Exemplo n.º 2
0
/**
 * Ensures that a javascript cache file exists and if it doesn't, will create
 * the necessary JS Groupings files into the cache directory for consumption.
 *
 * @param array $files The basename of the file to check or an array of names to check
 * @param string $root The directory off which the cache file path lives
 * @param boolean $addPath Adds the path to the cache for this file if true
 * @return string|array The path to the single file specified, or the collection of files specified
 */
function ensureJSCacheFilesExist($files = array(), $root = '.', $addPath = true)
{
    // Create a reasonable default. Using sugar_sidecar since that is what was
    // used in ensureCache as a default
    if (empty($files)) {
        $files = array('sugar_sidecar.min.js');
    }
    // Make this an array to facilitate more than one file check
    if (!is_array($files)) {
        $files = array($files);
    }
    // Prepare the return
    $return = array();
    // Check existence of files to allow building only when necessary
    $cacheExists = true;
    foreach ($files as $f) {
        // Build the path to the file we are looking for
        if ($addPath) {
            $path = "{$root}/" . sugar_cached("include/javascript/{$f}");
        } else {
            $path = "{$root}/{$f}";
        }
        // Keep track of existence
        $cacheExists = $cacheExists && file_exists($path) && is_file($path);
        // Add this file to the return stack
        $return[] = $path;
    }
    // If even one of the files doesn't exist, rebuild
    if (!$cacheExists) {
        // Maintain state as well as possible
        $rd = isset($_REQUEST['root_directory']) ? $_REQUEST['root_directory'] : null;
        // Build the concatenated files
        $_REQUEST['root_directory'] = $root;
        require_once "jssource/minify_utils.php";
        $minifyUtils = new SugarMinifyUtils();
        $minifyUtils->ConcatenateFiles($root);
        // Cleanup the root directory request var if it was found. If it was null
        // this will in effect unset it
        $_REQUEST['root_directory'] = $rd;
    }
    // For a single file check return just that file
    if (count($return) == 1) {
        return $return[0];
    }
    // For multiple file checks return all files
    return $return;
}
Exemplo n.º 3
0
ini_set('max_execution_time', '600');
//figure out which commands to call.
if ($_REQUEST['js_admin_repair'] == 'concat') {
    //concatenate mode, call the files that will concatenate javascript group files
    $_REQUEST['js_rebuild_concat'] = 'rebuild';
    require_once 'jssource/minify.php';
} else {
    if ($_REQUEST['js_admin_repair'] === 'sidecar') {
        $dir = getcwd();
        chdir('sidecar');
        shell_exec('php -f build.php p');
        chdir($dir);
    } else {
        $_REQUEST['root_directory'] = getcwd();
        require_once 'jssource/minify.php';
        $minifyUtils = new SugarMinifyUtils();
        if ($_REQUEST['js_admin_repair'] == 'replace') {
            //should replace compressed JS with source js
            $minifyUtils->reverseScripts("{$from}/jssource/src_files", "{$from}");
        } elseif ($_REQUEST['js_admin_repair'] == 'mini') {
            //should replace compressed JS with minified version of source js
            $minifyUtils->reverseScripts("{$from}/jssource/src_files", "{$from}");
            $minifyUtils->BackUpAndCompressScriptFiles("{$from}", "", false);
            $minifyUtils->ConcatenateFiles("{$from}");
        } elseif ($_REQUEST['js_admin_repair'] == 'repair') {
            //should compress existing javascript (including changes done) without overwriting original source files
            $minifyUtils->BackUpAndCompressScriptFiles("{$from}", "", false);
            $minifyUtils->ConcatenateFiles("{$from}");
        }
    }
}
Exemplo n.º 4
0
    protected function _displayLoginJS()
    {
        global $sugar_config, $timedate;
        if (isset($this->bean->module_dir)) {
            echo "<script>var module_sugar_grp1 = '{$this->bean->module_dir}';</script>";
        }
        if (isset($_REQUEST['action'])) {
            echo "<script>var action_sugar_grp1 = '{$_REQUEST['action']}';</script>";
        }
        echo '<script>jscal_today = 1000*' . $timedate->asUserTs($timedate->getNow()) . '; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
        if (!is_file(sugar_cached("include/javascript/sugar_grp1.js"))) {
            $_REQUEST['root_directory'] = ".";
            require_once "jssource/minify_utils.php";
            $minifyUtils = new SugarMinifyUtils();
            $minifyUtils->ConcatenateFiles(".");
        }
        echo getVersionedScript('cache/include/javascript/sugar_grp1_jquery.js');
        echo getVersionedScript('cache/include/javascript/sugar_grp1_yui.js');
        echo getVersionedScript('cache/include/javascript/sugar_grp1.js');
        if (!is_file(sugar_cached("Expressions/functions_cache.js"))) {
            $GLOBALS['updateSilent'] = true;
            include "include/Expressions/updatecache.php";
        }
        if (inDeveloperMode()) {
            echo getVersionedScript('cache/Expressions/functions_cache_debug.js');
        } else {
            echo getVersionedScript('cache/Expressions/functions_cache.js');
        }
        echo <<<EOQ
        <script>
            if ( typeof(SUGAR) == 'undefined' ) {SUGAR = {}};
            if ( typeof(SUGAR.themes) == 'undefined' ) SUGAR.themes = {};
        </script>
EOQ;
        if (isset($sugar_config['disc_client']) && $sugar_config['disc_client']) {
            echo getVersionedScript('modules/Sync/headersync.js');
        }
    }
Exemplo n.º 5
0
         require_once $from . '/./include/utils.php';
         require_once $from . '/./include/utils/file_utils.php';
         require_once $from . '/./include/utils/sugar_file_utils.php';
         require_once $from . '/./include/dir_inc.php';
     }
     if (!function_exists('sugar_cached')) {
         function sugar_cached($dir)
         {
             return "cache/{$dir}";
         }
     }
 }
 if ($argv[1] == '-?') {
     $argv[2] = '-?';
 }
 $minifyUtils = new SugarMinifyUtils();
 //if second argument is set, then process commands
 if (!empty($argv[2])) {
     if ($argv[2] == '-r') {
         //replace the compressed scripts with the backed up version
         $minifyUtils->reverseScripts("{$from}/jssource/src_files", $from);
     } elseif ($argv[2] == '-m') {
         //replace the scripts, and then minify the scripts again
         $minifyUtils->reverseScripts("{$from}/jssource/src_files", $from);
         $minifyUtils->BackUpAndCompressScriptFiles($from, "", false, true);
     } elseif ($argv[2] == '-c') {
         //replace the scripts, concatenate the files, and then minify the scripts again
         $minifyUtils->reverseScripts("{$from}/jssource/src_files", $from);
         $minifyUtils->BackUpAndCompressScriptFiles($from, "", false, true);
         $minifyUtils->ConcatenateFiles($from, true);
     } elseif ($argv[2] == '-mo') {