예제 #1
0
 /**
  * This method checks to see if the configuration file exists and, if not, creates one by default
  *
  */
 public function preDisplay()
 {
     global $app_strings;
     //Rebuild config file if it doesn't exist
     if (!file_exists($this->configFile)) {
         ModuleInstaller::handleBaseConfig();
     }
     $this->ss->assign("configFile", $this->configFile);
     $config = ModuleInstaller::getBaseConfig();
     $this->ss->assign('configHash', md5(serialize($config)));
     $sugarSidecarPath = ensureJSCacheFilesExist();
     $this->ss->assign("sugarSidecarPath", $sugarSidecarPath);
     // TODO: come up with a better way to deal with the various JS files
     // littered in sidecar.tpl.
     $voodooFile = 'custom/include/javascript/voodoo.js';
     if (SugarAutoLoader::fileExists($voodooFile)) {
         $this->ss->assign('voodooFile', $voodooFile);
     }
     //Load sidecar theme css
     $theme = new SidecarTheme();
     $this->ss->assign("css_url", $theme->getCSSURL());
     $this->ss->assign("developerMode", inDeveloperMode());
     //Loading label
     $this->ss->assign('LBL_LOADING', $app_strings['LBL_ALERT_TITLE_LOADING']);
     $this->ss->assign('LBL_ENABLE_JAVASCRIPT', $app_strings['LBL_ENABLE_JAVASCRIPT']);
     $slFunctionsPath = inDeveloperMode() ? "cache/Expressions/functions_cache_debug.js" : "cache/Expressions/functions_cache.js";
     if (!is_file($slFunctionsPath)) {
         $GLOBALS['updateSilent'] = true;
         include "include/Expressions/updatecache.php";
     }
     $this->ss->assign("SLFunctionsPath", $slFunctionsPath);
     if (!empty($this->authorization)) {
         $this->ss->assign('appPrefix', $config['env'] . ":" . $config['appId'] . ":");
         $this->ss->assign('authorization', $this->authorization);
     }
 }
예제 #2
0
 /**
  * Ensures that necessary client files are in place 
  * 
  * @return boolean
  */
 protected function ensureClientFiles()
 {
     ensureJSCacheFilesExist($this->clientFiles, '.', false);
     return true;
 }
예제 #3
0
    /**
     * Called from process(). This method will display the correct javascript.
     */
    protected function _displayJavascript()
    {
        global $locale, $sugar_config, $timedate;
        if ($this->_getOption('show_javascript')) {
            if (!$this->_getOption('show_header')) {
                $langHeader = get_language_header();
                echo <<<EOHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html {$langHeader}>
<head>
EOHTML;
            }
            $js_vars = array("sugar_cache_dir" => "cache/");
            if (isset($this->bean->module_dir)) {
                $js_vars['module_sugar_grp1'] = $this->bean->module_dir;
            }
            if (isset($_REQUEST['action'])) {
                $js_vars['action_sugar_grp1'] = $_REQUEST['action'];
            }
            echo '<script>jscal_today = 1000*' . $timedate->asUserTs($timedate->getNow()) . '; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
            // Make sure the necessary cache files are in place
            $jsFiles = array("sugar_grp1.js", "sugar_grp1_yui.js", "sugar_grp1_jquery.js");
            ensureJSCacheFilesExist($jsFiles);
            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');
            $version_mark = getVersionedPath(null);
            echo '<script>SUGAR = SUGAR || {}; SUGAR.VERSION_MARK = ' . json_encode($version_mark) . ';</script>';
            // output necessary config js in the top of the page
            $config_js = $this->getSugarConfigJS();
            if (!empty($config_js)) {
                echo "<script>\n" . implode("\n", $config_js) . "</script>\n";
            }
            // CSRF form token
            echo $this->getCsrfFormTokenJscript();
            if (isset($sugar_config['email_sugarclient_listviewmaxselect'])) {
                echo "<script>SUGAR.config.email_sugarclient_listviewmaxselect = {$GLOBALS['sugar_config']['email_sugarclient_listviewmaxselect']};</script>";
            }
            $image_server = defined('TEMPLATE_URL') ? TEMPLATE_URL . '/' : '';
            echo '<script type="text/javascript">SUGAR.themes.image_server="' . $image_server . '";</script>';
            // cn: bug 12274 - create session-stored key to defend against CSRF
            echo '<script type="text/javascript">var name_format = "' . $locale->getLocaleFormatMacro() . '";</script>';
            echo self::getJavascriptValidation();
            if (!is_file(sugar_cached('jsLanguage/') . $GLOBALS['current_language'] . '.js')) {
                require_once 'include/language/jsLanguage.php';
                jsLanguage::createAppStringsCache($GLOBALS['current_language']);
            }
            echo getVersionedScript('cache/jsLanguage/' . $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
            echo $this->_getModLanguageJS();
            echo getVersionedScript('include/javascript/productTour.js');
            if (isset($sugar_config['disc_client']) && $sugar_config['disc_client']) {
                echo getVersionedScript('modules/Sync/headersync.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');
            }
            require_once "include/Expressions/DependencyManager.php";
            echo "\n" . '<script type="text/javascript">' . DependencyManager::getJSUserVariables($GLOBALS['current_user']) . "</script>\n";
            //echo out the $js_vars variables as javascript variables
            echo "<script type='text/javascript'>\n";
            foreach ($js_vars as $var => $value) {
                echo "var {$var} = '{$value}';\n";
            }
            echo "</script>\n";
        }
    }