From 607236a7cbd7e27a0e41bb454fae11572f0d4eec Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Thu, 29 Aug 2013 08:35:44 +0000 Subject: [PATCH] Compiler: added brand management SVN:trunk[2838] --- application/itopwebpage.class.inc.php | 12 ++++-- application/loginwebpage.class.inc.php | 18 +++++++-- application/portalwebpage.class.inc.php | 15 +++++++- pages/logoff.php | 9 ++++- portal/index.php | 2 +- setup/compiler.class.inc.php | 50 ++++++++++++++++++++++++- 6 files changed, 93 insertions(+), 13 deletions(-) diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php index 9fe19a344..67fb29c75 100644 --- a/application/itopwebpage.class.inc.php +++ b/application/itopwebpage.class.inc.php @@ -1,5 +1,5 @@ Get('online_help'); //$sLogOffMenu = ""; + $sDisplayIcon = utils::GetAbsoluteUrlAppRoot().'images/itop-logo.png'; + if (file_exists(MODULESROOT.'branding/main-logo.png')) + { + $sDisplayIcon = utils::GetAbsoluteUrlModulesRoot().'branding/main-logo.png'; + } + $sHtml .= $sNorthPane; $sHtml .= '
'; $sHtml .= ''; $sHtml .= '
'; $sHtml .= ' '; $sHtml .= '
'; $sHtml .= '
pin
'; diff --git a/application/loginwebpage.class.inc.php b/application/loginwebpage.class.inc.php index 792f4f405..939ae65eb 100644 --- a/application/loginwebpage.class.inc.php +++ b/application/loginwebpage.class.inc.php @@ -1,5 +1,5 @@ Get('app_icon_url'); - $this->add("
\n"); + $sDisplayIcon = utils::GetAbsoluteUrlAppRoot().'images/itop-logo-external.png'; + if (file_exists(MODULESROOT.'branding/login-logo.png')) + { + $sDisplayIcon = utils::GetAbsoluteUrlModulesRoot().'branding/login-logo.png'; + } + $this->add("
\n"); $this->add("
\n"); $this->add("

".Dict::S('UI:Login:Welcome')."

\n"); if ($bFailedLogin) @@ -199,7 +204,12 @@ function DoCheckPwd() EOF ); $sIconUrl = Utils::GetConfig()->Get('app_icon_url'); - $this->add("
\n"); + $sDisplayIcon = utils::GetAbsoluteUrlAppRoot().'images/itop-logo.png'; + if (file_exists(MODULESROOT.'branding/main-logo.png')) + { + $sDisplayIcon = utils::GetAbsoluteUrlModulesRoot().'branding/main-logo.png'; + } + $this->add("
\n"); $this->add("
\n"); $this->add("

".Dict::S('UI:Login:ChangeYourPassword')."

\n"); if ($bFailedLogin) diff --git a/application/portalwebpage.class.inc.php b/application/portalwebpage.class.inc.php index 641d22c31..de350b48d 100644 --- a/application/portalwebpage.class.inc.php +++ b/application/portalwebpage.class.inc.php @@ -1,5 +1,5 @@ add('
'); + + // Customize the logo (unless a customer CSS has been defined) + if ($sAlternateStyleSheet == '') + { + if (file_exists(MODULESROOT.'branding/portal-logo.png')) + { + $sDisplayIcon = utils::GetAbsoluteUrlModulesRoot().'branding/portal-logo.png'; + $this->add_style("div#portal #logo {background: url(\"$sDisplayIcon\") no-repeat scroll 0 0 transparent;}"); + } + } + } public function SetCurrentTab($sTabLabel = '') diff --git a/pages/logoff.php b/pages/logoff.php index 581e65268..97b4bc1ea 100644 --- a/pages/logoff.php +++ b/pages/logoff.php @@ -1,5 +1,5 @@ no_cache(); $sVersionShort = Dict::Format('UI:iTopVersion:Short', ITOP_VERSION); $sIconUrl = Utils::GetConfig()->Get('app_icon_url'); -$oPage->add("
\n"); +$sDisplayIcon = utils::GetAbsoluteUrlAppRoot().'images/itop-logo-external.png'; +if (file_exists(MODULESROOT.'branding/login-logo.png')) +{ + $sDisplayIcon = utils::GetAbsoluteUrlModulesRoot().'branding/login-logo.png'; +} +$oPage->add("
\n"); $oPage->add("
\n"); $oPage->add("

".Dict::S('UI:LogOff:ThankYou')."

\n"); diff --git a/portal/index.php b/portal/index.php index 87b44eca8..9b2731bb8 100644 --- a/portal/index.php +++ b/portal/index.php @@ -19,7 +19,7 @@ /** * iTop User Portal main page * - * @copyright Copyright (C) 2010-2012 Combodo SARL + * @copyright Copyright (C) 2010-2013 Combodo SARL * @license http://opensource.org/licenses/AGPL-3.0 */ require_once('../approot.inc.php'); diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php index 19dee49a0..894d483c5 100644 --- a/setup/compiler.class.inc.php +++ b/setup/compiler.class.inc.php @@ -316,7 +316,13 @@ EOF; { $this->CompileDictionary($oDictionaryNode, $sTempTargetDir, $sFinalTargetDir); } - } // Compile() + + // Compile the branding + // + $oBrandingNode = $this->oFactory->GetNodes('branding')->item(0); + $this->CompileBranding($oBrandingNode, $sTempTargetDir, $sFinalTargetDir); + + } // DoCompile() /** * Helper to form a valid ZList from the array built by GetNodeAsArrayOfItems() @@ -1537,6 +1543,48 @@ EOF; } } } + + + protected function CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, $sNodeName, $sTargetFile) + { + if (($sIcon = $oBrandingNode->GetChildText($sNodeName)) && (strlen($sIcon) > 0)) + { + if (substr($sIcon, 0, 8) == 'branding') + { + $sSourceFile = $sTempTargetDir.'/'.$sIcon; + } + else + { + $sSourceFile = APPROOT.$sIcon; + } + $sTargetFile = $sTempTargetDir.'/branding/'.$sTargetFile.'.png'; + + if (!file_exists($sSourceFile)) + { + throw new Exception("Branding $sNodeName: could not find the file $sIcon ($sSourceFile)"); + } + + // Note: rename makes sense only when the file given as a file ref, otherwise it may be an item of the application (thus it must be kept there) + copy($sSourceFile, $sTargetFile); + } + } + + protected function CompileBranding($oBrandingNode, $sTempTargetDir, $sFinalTargetDir) + { + if ($oBrandingNode) + { + // Transform file refs into files in the images folder + SetupUtils::builddir($sTempTargetDir.'/branding'); + $this->CompileFiles($oBrandingNode, $sTempTargetDir.'/branding', $sFinalTargetDir.'/branding', 'branding'); + + $this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'main_logo', 'main-logo'); + $this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'login_logo', 'login-logo'); + $this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'portal_logo', 'portal-logo'); + + // Cleanup the images directory (made by CompileFiles) + SetupUtils::rrmdir($sTempTargetDir.'/branding/images'); + } + } } ?> \ No newline at end of file