/** * @param bool $bAdmin * * @return array */ private function startUpData($bAdmin) { $sLanguage = 'en'; $sTheme = 'Default'; if (!$bAdmin) { list($sLanguage, $sTheme) = $this->oActions->GetLanguageAndTheme(); } $sLanguage = $this->oActions->ValidateLanguage($sLanguage); $sTheme = $this->oActions->ValidateTheme($sTheme); $bAppJsDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_js', false); $bAppCssDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_css', false); $sStaticPrefix = APP_WEB_STATIC_PATH; return array('Language' => $sLanguage, 'Theme' => $sTheme, 'Hash' => $this->generateIndexCacheHash($bAppJsDebug, $bAdmin), 'LoadingDescription' => $this->oActions->Config()->Get('webmail', 'loading_description', 'RainLoop'), 'FaviconIcoLink' => $sStaticPrefix . 'favicon.ico', 'FaviconPngLink' => $sStaticPrefix . 'favicon.png', 'AppleTouchLink' => $sStaticPrefix . 'apple-touch-icon.png', 'AppCssLink' => $sStaticPrefix . 'css/app' . ($bAppCssDebug ? '' : '.min') . '.css', 'LibJsLink' => $sStaticPrefix . 'js/libs.js', 'EditorJsLink' => $sStaticPrefix . 'ckeditor/ckeditor.js', 'AppJsLink' => $sStaticPrefix . 'js/' . ($bAdmin ? 'admin' : 'app') . ($bAppJsDebug ? '' : '.min') . '.js'); }
/** * @param bool $bAdmin * * @return array */ private function indexTemplateParameters($bAdmin) { $sLanguage = 'en'; $sTheme = 'Default'; if (!$bAdmin) { list($sLanguage, $sTheme) = $this->oActions->GetLanguageAndTheme(); } $sLanguage = $this->oActions->ValidateLanguage($sLanguage); $sTheme = $this->oActions->ValidateTheme($sTheme); $bAppJsDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_js', false); $bAppCssDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_css', false); $sStaticPrefix = APP_WEB_STATIC_PATH; $aData = array('Language' => $sLanguage, 'Theme' => $sTheme, 'LoadingDescription' => $this->oActions->Config()->Get('webmail', 'loading_description', 'RainLoop'), 'FaviconIcoLink' => $sStaticPrefix . 'favicon.ico', 'FaviconPngLink' => $sStaticPrefix . 'favicon.png', 'AppleTouchLink' => $sStaticPrefix . 'apple-touch-icon.png', 'AppCssLink' => $sStaticPrefix . 'css/app' . ($bAppCssDebug ? '' : '.min') . '.css', 'BootJsLink' => $sStaticPrefix . 'js/min/boot.js', 'LibJsLink' => $sStaticPrefix . 'js/min/libs.js', 'EditorJsLink' => $sStaticPrefix . 'ckeditor/ckeditor.js', 'OpenPgpJsLink' => $sStaticPrefix . 'js/min/openpgp.min.js', 'AppJsLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . ($bAdmin ? 'admin' : 'app') . '.js'); $aTemplateParameters = array('{{BaseAppDataScriptLink}}' => $bAdmin ? './?/AdminAppData/' : './?/AppData/', '{{BaseAppFaviconIcoFile}}' => $aData['FaviconIcoLink'], '{{BaseAppFaviconPngFile}}' => $aData['FaviconPngLink'], '{{BaseAppAppleTouchFile}}' => $aData['AppleTouchLink'], '{{BaseAppMainCssLink}}' => $aData['AppCssLink'], '{{BaseAppBootScriptLink}}' => $aData['BootJsLink'], '{{BaseAppLibsScriptLink}}' => $aData['LibJsLink'], '{{BaseAppEditorScriptLink}}' => $aData['EditorJsLink'], '{{BaseAppOpenPgpScriptLink}}' => $aData['OpenPgpJsLink'], '{{BaseAppMainScriptLink}}' => $aData['AppJsLink'], '{{BaseAppLoadingDescription}}' => \htmlspecialchars($aData['LoadingDescription'], ENT_QUOTES | ENT_IGNORE, 'UTF-8'), '{{BaseDir}}' => \in_array($aData['Language'], array('ar', 'he', 'ur')) ? 'rtl' : 'ltr'); $aTemplateParameters['{{BaseHash}}'] = \md5(\implode('~', array(\md5($this->oActions->Config()->Get('cache', 'index', '')), $this->oActions->Plugins()->Hash(), APP_WEB_PATH, APP_VERSION)) . \implode('~', $aTemplateParameters)); return $aTemplateParameters; }
/** * @param bool $bAdmin * * @return array */ private function indexTemplateParameters($bAdmin) { $sLanguage = 'en'; $sTheme = 'Default'; if (!$bAdmin) { list($sLanguage, $sTheme) = $this->oActions->GetLanguageAndTheme(); } $sLanguage = $this->oActions->ValidateLanguage($sLanguage); $sTheme = $this->oActions->ValidateTheme($sTheme); $bAppJsDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_js', false); $bAppCssDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_css', false); $sStaticPrefix = \RainLoop\Utils::WebStaticPath(); $aData = array('Language' => $sLanguage, 'Theme' => $sTheme, 'FaviconIcoLink' => $sStaticPrefix . 'favicon.ico', 'FaviconPngLink' => $sStaticPrefix . 'favicon.png', 'AppleTouchLink' => $sStaticPrefix . 'apple-touch-icon.png', 'AppCssLink' => $sStaticPrefix . 'css/app' . ($bAppCssDebug ? '' : '.min') . '.css', 'BootJsLink' => $sStaticPrefix . 'js/min/boot.js', 'ComponentsJsLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . 'components.js', 'LibJsLink' => $sStaticPrefix . 'js/min/libs.js', 'EditorJsLink' => $sStaticPrefix . 'ckeditor/ckeditor.js', 'OpenPgpJsLink' => $sStaticPrefix . 'js/min/openpgp.min.js', 'AppJsCommonLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . 'common.js', 'AppJsLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . ($bAdmin ? 'admin' : 'app') . '.js'); $aTemplateParameters = array('{{BaseAppDataScriptLink}}' => $bAdmin ? './?/AdminAppData/' : './?/AppData/', '{{BaseAppFaviconIcoFile}}' => $aData['FaviconIcoLink'], '{{BaseAppFaviconPngFile}}' => $aData['FaviconPngLink'], '{{BaseAppAppleTouchFile}}' => $aData['AppleTouchLink'], '{{BaseAppMainCssLink}}' => $aData['AppCssLink'], '{{BaseAppBootScriptLink}}' => $aData['BootJsLink'], '{{BaseAppComponentsScriptLink}}' => $aData['ComponentsJsLink'], '{{BaseAppLibsScriptLink}}' => $aData['LibJsLink'], '{{BaseAppEditorScriptLink}}' => $aData['EditorJsLink'], '{{BaseAppOpenPgpScriptLink}}' => $aData['OpenPgpJsLink'], '{{BaseAppMainCommonScriptLink}}' => $aData['AppJsCommonLink'], '{{BaseAppMainScriptLink}}' => $aData['AppJsLink'], '{{BaseDir}}' => \in_array($aData['Language'], array('ar', 'he', 'ur')) ? 'rtl' : 'ltr'); $aTemplateParameters['{{BaseHash}}'] = \md5(\implode('~', array(\md5($this->oActions->Config()->Get('cache', 'index', '')), $this->oActions->Plugins()->Hash(), \RainLoop\Utils::WebVersionPath(), APP_VERSION)) . \implode('~', $aTemplateParameters)); return $aTemplateParameters; }
/** * @return string */ public function ServiceCss() { $sResult = ''; $bAdmin = !empty($this->aPaths[2]) && 'Admin' === $this->aPaths[2]; $bJson = !empty($this->aPaths[9]) && 'Json' === $this->aPaths[9]; if ($bJson) { @\header('Content-Type: application/json; charset=utf-8'); } else { @\header('Content-Type: text/css; charset=utf-8'); } $sTheme = ''; if (!empty($this->aPaths[4])) { $sTheme = $this->oActions->ValidateTheme($this->aPaths[4]); $sRealTheme = $sTheme; $bCustomTheme = '@custom' === \substr($sTheme, -7); if ($bCustomTheme) { $sRealTheme = \substr($sTheme, 0, -7); } $bCacheEnabled = $this->Config()->Get('labs', 'cache_system_data', true); if ($bCacheEnabled) { $this->oActions->verifyCacheByKey($this->sQuery); } $sCacheFileName = ''; if ($bCacheEnabled) { $sCacheFileName = \RainLoop\KeyPathHelper::CssCache($sTheme, $this->oActions->Plugins()->Hash()); $sResult = $this->Cacher()->Get($sCacheFileName); } if (0 === \strlen($sResult)) { try { include_once APP_VERSION_ROOT_PATH . 'app/libraries/lessphp/ctype.php'; include_once APP_VERSION_ROOT_PATH . 'app/libraries/lessphp/lessc.inc.php'; $oLess = new \lessc(); $oLess->setFormatter('compressed'); $aResult = array(); $sThemeFile = ($bCustomTheme ? APP_INDEX_ROOT_PATH : APP_VERSION_ROOT_PATH) . 'themes/' . $sRealTheme . '/styles.less'; $sThemeExtFile = ($bCustomTheme ? APP_INDEX_ROOT_PATH : APP_VERSION_ROOT_PATH) . 'themes/' . $sRealTheme . '/ext.less'; $sThemeValuesFile = APP_VERSION_ROOT_PATH . 'app/templates/Themes/values.less'; $sThemeTemplateFile = APP_VERSION_ROOT_PATH . 'app/templates/Themes/template.less'; if (\file_exists($sThemeFile) && \file_exists($sThemeTemplateFile) && \file_exists($sThemeValuesFile)) { $aResult[] = '@base: "' . ($bCustomTheme ? \RainLoop\Utils::WebPath() : \RainLoop\Utils::WebVersionPath()) . 'themes/' . $sRealTheme . '/";'; $aResult[] = \file_get_contents($sThemeValuesFile); $aResult[] = \file_get_contents($sThemeFile); $aResult[] = \file_get_contents($sThemeTemplateFile); if (\file_exists($sThemeExtFile)) { $aResult[] = \file_get_contents($sThemeExtFile); } } $aResult[] = $this->Plugins()->CompileCss($bAdmin); $sResult = $oLess->compile(\implode("\n", $aResult)); if ($bCacheEnabled) { if (0 < \strlen($sCacheFileName)) { $this->Cacher()->Set($sCacheFileName, $sResult); } } } catch (\Exception $oException) { $this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR, 'LESS'); } } if ($bCacheEnabled) { $this->oActions->cacheByKey($this->sQuery); } } return $bJson ? \MailSo\Base\Utils::Php2js(array($sTheme, $sResult), $this->Logger()) : $sResult; }