diff options
author | mattpiwik <matthieu.aubry@gmail.com> | 2011-05-27 02:16:48 +0400 |
---|---|---|
committer | mattpiwik <matthieu.aubry@gmail.com> | 2011-05-27 02:16:48 +0400 |
commit | 804feaa9d1a41c9200f167af3e55d19efe5812da (patch) | |
tree | 96fe0986914e36b7b2a078c16dc0928438b7efa5 /plugins | |
parent | d32abe0123266062e95980e1a84bcfe8a1349ce6 (diff) |
Refs #2008
* keep uploaded logo ratio after resizing, just force the height (so it works for high logos, or wide logos)
git-svn-id: http://dev.piwik.org/svn/trunk@4817 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/API/API.php | 26 | ||||
-rw-r--r-- | plugins/CoreAdminHome/Controller.php | 67 | ||||
-rw-r--r-- | plugins/CoreAdminHome/templates/generalSettings.tpl | 13 | ||||
-rw-r--r-- | plugins/CoreHome/templates/logo.tpl | 6 | ||||
-rw-r--r-- | plugins/Login/templates/header.tpl | 2 |
5 files changed, 57 insertions, 57 deletions
diff --git a/plugins/API/API.php b/plugins/API/API.php index 2e22d275cd..862d001ecb 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -284,16 +284,16 @@ class Piwik_API_API */ public function getLogoUrl($pathOnly=false) { - if(Zend_Registry::get('config')->branding->use_custom_logo == 1 && file_exists(Piwik_Common::getPathToPiwikRoot() .'/themes/logo.png')) { + $logo = 'themes/default/images/logo.png'; + if(Zend_Registry::get('config')->branding->use_custom_logo == 1 + && file_exists(Piwik_Common::getPathToPiwikRoot() .'/themes/logo.png')) + { $logo = 'themes/logo.png'; - } else { - $logo = 'themes/default/images/logo.png'; - } + } if(!$pathOnly) { return Piwik::getPiwikUrl() . $logo; - } else { - return Piwik_Common::getPathToPiwikRoot() .'/'. $logo; - } + } + return Piwik_Common::getPathToPiwikRoot() .'/'. $logo; } /** @@ -301,16 +301,16 @@ class Piwik_API_API */ public function getHeaderLogoUrl($pathOnly=false) { - if(Zend_Registry::get('config')->branding->use_custom_logo == 1 && file_exists(Piwik_Common::getPathToPiwikRoot() .'/themes/logo-header.png')) { + $logo = 'themes/default/images/logo-header.png'; + if(Zend_Registry::get('config')->branding->use_custom_logo == 1 + && file_exists(Piwik_Common::getPathToPiwikRoot() .'/themes/logo-header.png')) + { $logo = 'themes/logo-header.png'; - } else { - $logo = 'themes/default/images/logo-header.png'; - } + } if(!$pathOnly) { return Piwik::getPiwikUrl() . $logo; - } else { - return Piwik_Common::getPathToPiwikRoot() .'/'. $logo; } + return Piwik_Common::getPathToPiwikRoot() .'/'. $logo; } /** diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php index a222944070..d8706c5f61 100644 --- a/plugins/CoreAdminHome/Controller.php +++ b/plugins/CoreAdminHome/Controller.php @@ -16,10 +16,8 @@ */ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin { - const LOGO_HEIGHT = 110; - const LOGO_WIDTH = 280; - const LOGO_SMALL_HEIGHT = 50; - const LOGO_SMALL_WIDTH = 127; + const LOGO_HEIGHT = 300; + const LOGO_SMALL_HEIGHT = 100; public function index() { @@ -129,35 +127,40 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin public function uploadCustomLogo() { - if(!empty($_FILES['customLogo']) && empty($_FILES['customLogo']['error'])) { - $file = $_FILES['customLogo']['tmp_name']; - $error = false; - - list($width, $height) = getimagesize($file); - - - switch($_FILES['customLogo']['type']) { - case 'image/jpeg': - $image = imagecreatefromjpeg($file); - break; - case 'image/png': - $image = imagecreatefrompng($file); - break; - default: - echo '0'; - return; - } - - $logo = imagecreatetruecolor(self::LOGO_WIDTH, self::LOGO_HEIGHT); - $logoSmall = imagecreatetruecolor(self::LOGO_SMALL_WIDTH, self::LOGO_SMALL_HEIGHT); - imagecopyresized($logo, $image, 0, 0, 0, 0, self::LOGO_WIDTH, self::LOGO_HEIGHT, $width, $height); - imagecopyresized($logoSmall, $image, 0, 0, 0, 0, self::LOGO_SMALL_WIDTH, self::LOGO_SMALL_HEIGHT, $width, $height); - - imagepng($logo, Piwik_Common::getPathToPiwikRoot().'/themes/logo.png', 3); - imagepng($logoSmall, Piwik_Common::getPathToPiwikRoot().'/themes/logo-header.png', 3); - echo '1'; + if(empty($_FILES['customLogo']) + || !empty($_FILES['customLogo']['error'])) + { + echo '0'; return; } - echo '0'; + + $file = $_FILES['customLogo']['tmp_name']; + $error = false; + + list($width, $height) = getimagesize($file); + switch($_FILES['customLogo']['type']) { + case 'image/jpeg': + $image = imagecreatefromjpeg($file); + break; + case 'image/png': + $image = imagecreatefrompng($file); + break; + default: + echo '0'; + return; + } + + $widthExpected = round($width * self::LOGO_HEIGHT / $height); + $smallWidthExpected = round($width * self::LOGO_SMALL_HEIGHT / $height); + + $logo = imagecreatetruecolor($widthExpected, self::LOGO_HEIGHT); + $logoSmall = imagecreatetruecolor($smallWidthExpected, self::LOGO_SMALL_HEIGHT); + imagecopyresized($logo, $image, 0, 0, 0, 0, $widthExpected, self::LOGO_HEIGHT, $width, $height); + imagecopyresized($logoSmall, $image, 0, 0, 0, 0, $smallWidthExpected, self::LOGO_SMALL_HEIGHT, $width, $height); + + imagepng($logo, Piwik_Common::getPathToPiwikRoot().'/themes/logo.png', 3); + imagepng($logoSmall, Piwik_Common::getPathToPiwikRoot().'/themes/logo-header.png', 3); + echo '1'; + return; } } diff --git a/plugins/CoreAdminHome/templates/generalSettings.tpl b/plugins/CoreAdminHome/templates/generalSettings.tpl index 88adc3aca8..072d5e9c0a 100644 --- a/plugins/CoreAdminHome/templates/generalSettings.tpl +++ b/plugins/CoreAdminHome/templates/generalSettings.tpl @@ -125,9 +125,10 @@ <h2>{'CoreAdminHome_BrandingSettings'|translate}</h2> <div id='brandSettings'> +{'CoreAdminHome_CustomLogoHelpText'|translate} <table class="adminTable" style='width:600px;'> <tr> - <td>{'CoreAdminHome_UseCustomLogo'|translate}</td> + <td> {'CoreAdminHome_UseCustomLogo'|translate}</td> <td style='width:200px'> <label><input type="radio" name="useCustomLogo" value="1" {if $branding.use_custom_logo == 1} checked {/if}> {'General_Yes'|translate}</label> <label><input type="radio" name="useCustomLogo" value="0" style ="margin-left:20px;" {if $branding.use_custom_logo == 0} checked {/if}> {'General_No'|translate}</label> @@ -136,19 +137,19 @@ </table> </div> <div id='logoSettings'> + {capture assign=giveUsFeedbackText}"{'General_GiveUsYourFeedback'|translate}"{/capture} {capture assign=customLogoHelp} - {'CoreAdminHome_CustomLogoHelpText'|translate}<br /><br /> - {'CoreAdminHome_CustomLogoFeedbackInfo'|translate:"<a href='?module=CorePluginsAdmin&action=index' target='_blank'>":"</a>"} + {'CoreAdminHome_CustomLogoFeedbackInfo'|translate:$giveUsFeedbackText:"<a href='?module=CorePluginsAdmin&action=index' target='_blank'>":"</a>"} {/capture} {$customLogoHelp|inlineHelp} <form id="logoUploadForm" method="post" enctype="multipart/form-data" action="index.php?module=CoreAdminHome&format=json&action=uploadCustomLogo"> <table class="adminTable" style='width:550px;'> <tr> {if $logosWriteable} - <td><label for="customLogo">{'CoreAdminHome_LogoUpload'|translate}<br> - <span class="form-description">{'CoreAdminHome_LogoUploadDescription'|translate}</span></label></td> + <td><label for="customLogo">{'CoreAdminHome_LogoUpload'|translate}:<br> + <span class="form-description">{'CoreAdminHome_LogoUploadDescription'|translate:"JPG / PNG"}</span></label></td> <td style='width:200px'> - <input name="customLogo" type="file" id="customLogo" /><img src="themes/logo.png" id="currentLogo" /> + <input name="customLogo" type="file" id="customLogo" /><img src="themes/logo.png?r={math equation='rand(10,1000)'}" id="currentLogo" height="150"/> </td> {else} <td><span class="ajaxSuccess">{'CoreAdminHome_LogoNotWriteable'|translate:"<ul style='list-style: disc inside;'><li>/themes/</li><li>/themes/logo.png</li><li>/themes/logo-header.png</li></ul>"}</span></td> diff --git a/plugins/CoreHome/templates/logo.tpl b/plugins/CoreHome/templates/logo.tpl index f22eb9c265..a12bb659c6 100644 --- a/plugins/CoreHome/templates/logo.tpl +++ b/plugins/CoreHome/templates/logo.tpl @@ -1,9 +1,5 @@ <span id="logo"> <a href="index.php" title="{if $isCustomLogo}{'General_PoweredBy'|translate} {/if}Piwik # {'General_OpenSourceWebAnalytics'|translate}" style="text-decoration: none;"> - <img src='{$headerLogo}' alt="{if $isCustomLogo}{'General_PoweredBy'|translate} {/if}Piwik" style='margin-left:10px' /> - {* - Text logo: <span style="color: rgb(245, 223, 114);">P</span><span style="color: rgb(241, 175, 108);">i</span><span style="color: rgb(241, 117, 117);">w</span><span style="color: rgb(155, 106, 58);">i</span><span style="color: rgb(107, 50, 11);">k</span> - *} - + <img src='{$logoHeader}' alt="{if $isCustomLogo}{'General_PoweredBy'|translate} {/if}Piwik" style='margin-left:10px' height='50px'/> </a> </span> diff --git a/plugins/Login/templates/header.tpl b/plugins/Login/templates/header.tpl index 338b9002fe..90d18ed16e 100644 --- a/plugins/Login/templates/header.tpl +++ b/plugins/Login/templates/header.tpl @@ -57,7 +57,7 @@ {include file="default/ie6.tpl"} <div id="logo"> <a href="http://piwik.org" title="{$linkTitle}"> - <img src='{$logo}' width='200' style='margin-right:20px'> + <img src='{$logoLarge}' width='200' style='margin-right:20px'> <div class="description"># {$linkTitle}</div> </a> </div> |