/** * This function loads portal config vars from db and sets them for the view * @see SugarView::display() for more info */ function display() { global $current_user, $app_strings; $smarty = new Sugar_Smarty(); $smarty->assign('mod', $GLOBALS['mod_strings']); $smarty->assign("token", session_id()); $smarty->assign("siteURL", $GLOBALS['sugar_config']['site_url']); //Loading label $smarty->assign('LBL_LOADING', $app_strings['LBL_ALERT_TITLE_LOADING']); $theme = new SidecarTheme(); $smarty->assign("css_url", $theme->getCSSURL()); $ajax = new AjaxCompose(); $ajax->addCrumb(translate('LBL_SUGARPORTAL', 'ModuleBuilder'), 'ModuleBuilder.main("sugarportal")'); $ajax->addCrumb(ucwords(translate('LBL_PORTAL_THEME')), ''); $ajax->addSection('center', translate('LBL_SUGARPORTAL', 'ModuleBuilder'), $smarty->fetch('modules/ModuleBuilder/tpls/portaltheme.tpl')); echo $ajax->getJavascript(); }
/** * 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); } }
} /* * Your installation or use of this SugarCRM file is subject to the applicable * terms available at * http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/. * If you do not agree to all of the applicable terms or do not have the * authority to bind the entity as an authorized representative, then do not * install or use this SugarCRM file. * * Copyright (C) SugarCRM Inc. All rights reserved. */ /** * This file is here to provide a HTML template for the rest help api. */ $theme = new SidecarTheme(); $bootstrap_css = $theme->getCSSURL(); // Fixes pathing for help requests ending in '/' $base_path = '../../../'; $link_path = '../'; if (substr($_SERVER['REQUEST_URI'], -1) == '/') { $base_path .= '../'; $link_path .= '../'; } ?> <!DOCTYPE HTML> <html> <head> <title>SugarCRM Auto Generated API Exceptions Documentation</title> <?php
/** * Updates variables.less with the values given in the request. * * @param ServiceBase $api * @param array $args * * @return array Locations of CSS files * @throws SugarApiExceptionNotAuthorized * @throws SugarApiExceptionMissingParameter */ public function updateCustomTheme(ServiceBase $api, array $args) { if (!$api->user->isAdmin()) { throw new SugarApiExceptionNotAuthorized(); } if (empty($args)) { throw new SugarApiExceptionMissingParameter('Missing colors'); } // Validating arguments $platform = isset($args['platform']) ? $args['platform'] : 'base'; $themeName = isset($args['themeName']) ? $args['themeName'] : null; $theme = new SidecarTheme($platform, $themeName); // if reset=true is passed if (!empty($args['reset'])) { $theme->saveThemeVariables($args['reset']); } else { // else $theme->loadVariables(); // Override the custom variables.less with the given vars $variables = array_diff_key($args, array('platform' => 0, 'themeName' => 0, 'reset' => 0)); $theme->setVariables($variables); $theme->saveThemeVariables(); } // saves the bootstrap.css URL in the portal settings $urls = $theme->getCSSURL(); foreach ($urls as $key => $url) { $urls[$key] = $GLOBALS['sugar_config']['site_url'] . '/' . $url; } $GLOBALS['system_config']->saveSetting($platform, 'css', json_encode($urls)); return $urls; }
/** * Retrieve CSS files from cache for this theme * Compile missing files if the theme has metadata definition * Compile default theme otherwise * * @return array Locations of CSS files for this theme */ public function getCSSURL() { $filesInCache = $this->retrieveCssFilesInCache(); // Remove the custom css file if the less file does not exist anymore if (isset($filesInCache['custom']) && !in_array('custom', $this->lessFilesToCompile)) { unlink($this->getCssFileLocation('custom', $filesInCache['custom'])); unset($filesInCache['custom']); } //If we found css files in cache we can return css urls if (count($filesInCache) === count($this->lessFilesToCompile)) { return $this->returnFileLocations($filesInCache); } //Since we did not find css files in cache we have to compile the theme. //First check if the theme has metadata, otherwise compile the default theme instead if ($this->myTheme !== 'default' && !$this->isDefined()) { $clientDefaultTheme = new SidecarTheme($this->myClient, 'default'); return $clientDefaultTheme->getCSSURL(); } //Arrived here we are going to compile missing css files $missingFiles = array_diff($this->lessFilesToCompile, array_keys($filesInCache)); foreach ($missingFiles as $lessFile) { $filesInCache[$lessFile] = $this->compileFile($lessFile); } return $this->returnFileLocations($filesInCache); }