diff options
-rw-r--r-- | config/global.ini.php | 5 | ||||
-rw-r--r-- | core/Controller.php | 3 | ||||
-rw-r--r-- | core/Piwik.php | 10 | ||||
-rw-r--r-- | core/ReportRenderer/Html.php | 1 | ||||
-rw-r--r-- | core/ReportRenderer/Pdf.php | 2 | ||||
-rw-r--r-- | lang/en.php | 8 | ||||
-rw-r--r-- | plugins/API/API.php | 35 | ||||
-rw-r--r-- | plugins/CoreAdminHome/Controller.php | 52 | ||||
-rw-r--r-- | plugins/CoreAdminHome/templates/generalSettings.js | 42 | ||||
-rw-r--r-- | plugins/CoreAdminHome/templates/generalSettings.tpl | 37 | ||||
-rw-r--r-- | plugins/CoreAdminHome/templates/styles.css | 6 | ||||
-rw-r--r-- | plugins/CoreHome/templates/html_report_header.tpl | 2 | ||||
-rw-r--r-- | plugins/CoreHome/templates/logo.tpl | 4 | ||||
-rw-r--r-- | plugins/Login/Controller.php | 2 | ||||
-rw-r--r-- | plugins/Login/templates/header.tpl | 2 |
15 files changed, 192 insertions, 19 deletions
diff --git a/config/global.ini.php b/config/global.ini.php index e787cc6074..c748f87ccc 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -334,6 +334,11 @@ ip_address_mask_length = 1 ; If you define Custom Variables for your visitor, for example set the visit type ;Segments[]="customVariableName1==VisitType;customVariableValue1==Customer" +[branding] +; custom logo +; if 1, custom logo is being displayed instead of piwik logo +use_custom_logo = 0 + [mail] defaultHostnameIfEmpty = defaultHostnameIfEmpty.example.org ; default Email @hostname, if current host can't be read from system variables transport = ; smtp (using the configuration below) or empty (using built-in mail() function) diff --git a/core/Controller.php b/core/Controller.php index 1f42dc9f79..bf54944400 100644 --- a/core/Controller.php +++ b/core/Controller.php @@ -374,6 +374,9 @@ abstract class Piwik_Controller $view->topMenu = Piwik_GetTopMenu(); $view->debugTrackVisitsInsidePiwikUI = Zend_Registry::get('config')->Debug->track_visits_inside_piwik_ui; $view->isSuperUser = Zend_Registry::get('access')->isSuperUser(); + $view->isCustomLogo = Zend_Registry::get('config')->branding->use_custom_logo; + $view->headerLogo = Piwik_API_API::getInstance()->getHeaderLogoUrl(); + $view->logo = Piwik_API_API::getInstance()->getLogoUrl(); } /** diff --git a/core/Piwik.php b/core/Piwik.php index 0bba4bf687..42484234eb 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -1453,16 +1453,6 @@ class Piwik } /** - * Returns relative path to the application logo - * - * @return string Absolute path to application logo - */ - public function getLogoPath() - { - return Piwik_Common::getPathToPiwikRoot() . '/themes/default/images/logo.png'; - } - - /** * Returns the Javascript code to be inserted on every page to track * * @param int $idSite diff --git a/core/ReportRenderer/Html.php b/core/ReportRenderer/Html.php index 9506509af0..9577a6a715 100644 --- a/core/ReportRenderer/Html.php +++ b/core/ReportRenderer/Html.php @@ -99,6 +99,7 @@ class Piwik_ReportRenderer_Html extends Piwik_ReportRenderer $smarty->assign("reportTableRowTextSize", self::REPORT_TABLE_ROW_TEXT_SIZE); $smarty->assign("reportBackToTopTextSize", self::REPORT_BACK_TO_TOP_TEXT_SIZE); $smarty->assign("currentPath", Piwik::getPiwikUrl()); + $smarty->assign("logoHeader", Piwik_API_API::getInstance()->getHeaderLogoUrl()); } public function renderReport($processedReport) diff --git a/core/ReportRenderer/Pdf.php b/core/ReportRenderer/Pdf.php index 05fc1ff245..00fe38407d 100644 --- a/core/ReportRenderer/Pdf.php +++ b/core/ReportRenderer/Pdf.php @@ -131,7 +131,7 @@ class Piwik_ReportRenderer_Pdf extends Piwik_ReportRenderer $this->TCPDF->SetFont($this->reportFont, $this->reportFontStyle, $this->reportSimpleFontSize); //Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false) { $this->TCPDF->Bookmark(Piwik_Translate('PDFReports_FrontPage')); - $this->TCPDF->Image(Piwik::getLogoPath(), $this->logoImagePosition[0], $this->logoImagePosition[1], 180 / $factor = 2, 0, $type = '', $link = '', $align = '', $resize = false, $dpi = 300); + $this->TCPDF->Image(Piwik_API_API::getInstance()->getLogoUrl(true), $this->logoImagePosition[0], $this->logoImagePosition[1], 180 / $factor = 2, 0, $type = '', $link = '', $align = '', $resize = false, $dpi = 300); $this->TCPDF->Ln(8); $websiteTitle = $this->formatText(Piwik_Translate('General_Website') . " " . $websiteName); diff --git a/lang/en.php b/lang/en.php index 768c991d15..0fe9535ab5 100644 --- a/lang/en.php +++ b/lang/en.php @@ -39,6 +39,7 @@ $translations = array( 'General_Username' => 'Username', 'General_Description' => 'Description', 'General_Done' => 'Done', + 'General_PoweredBy' => 'Powered by', 'General_Name' => 'Name', 'General_Value' => 'Value', 'General_AverageOrderValue' => 'Average Order Value', @@ -332,6 +333,13 @@ $translations = array( 'CoreAdminHome_YouAreOptedOut' => 'You are currently opted out.', 'CoreAdminHome_ClickHereToOptOut' => 'Click here to opt out.', 'CoreAdminHome_ClickHereToOptIn' => 'Click here to opt in.', + 'CoreAdminHome_BrandingSettings' => 'Branding settings', + 'CoreAdminHome_CustomLogoHelpText' => 'You can customize the Piwik logo which will be displayed in the user interface and email reports.', + 'CoreAdminHome_CustomLogoFeedbackInfo' => 'If you customize the Piwik logo, you might also be interested to hide the "Feedback" link in the top menu. To do so, you can disable the Feedback plugin in the %sManage Plugins%s page.', + 'CoreAdminHome_UseCustomLogo' => 'Use a custom logo', + 'CoreAdminHome_LogoUpload' => 'Fileupload for custom logo', + 'CoreAdminHome_LogoUploadDescription' => 'Please upload a file with a size of 280x110 or with an equal aspect ratio.', + 'CoreAdminHome_LogoNotWriteable' => 'To use a custom logo Piwik requires write access to the logo files within the themes directory: %s', 'CoreHome_PluginDescription' => 'Web Analytics Reports Structure.', 'CoreHome_WebAnalyticsReports' => 'Web Analytics Reports', 'CoreHome_NoPrivilegesAskPiwikAdmin' => 'You are logged in as \'%s\' but it seems you don\'t have any permission set in Piwik. %s Ask your Piwik administrator (click to email)%s to give you \'view\' access to a website.', diff --git a/plugins/API/API.php b/plugins/API/API.php index 690a08779d..2e22d275cd 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -278,6 +278,41 @@ class Piwik_API_API } return $compare; } + + /** + * Returns the url to application logo (~280x110px) + */ + 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/logo.png'; + } else { + $logo = 'themes/default/images/logo.png'; + } + if(!$pathOnly) { + return Piwik::getPiwikUrl() . $logo; + } else { + return Piwik_Common::getPathToPiwikRoot() .'/'. $logo; + } + } + + /** + * Returns the url to header logo (~127x50px) + */ + 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/logo-header.png'; + } else { + $logo = 'themes/default/images/logo-header.png'; + } + if(!$pathOnly) { + return Piwik::getPiwikUrl() . $logo; + } else { + return Piwik_Common::getPathToPiwikRoot() .'/'. $logo; + } + } + /** * Loads reports metadata, then return the requested one, * matching optional API parameters. diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php index 52442370fb..a222944070 100644 --- a/plugins/CoreAdminHome/Controller.php +++ b/plugins/CoreAdminHome/Controller.php @@ -16,6 +16,11 @@ */ 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; + public function index() { return $this->redirectToIndex('UsersManager', 'userSettings'); @@ -45,6 +50,14 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin $view->configFileNotWritable = true; } $view->mail = Zend_Registry::get('config')->mail->toArray(); + + $view->branding = Zend_Registry::get('config')->branding->toArray(); + + $directoryWritable = is_writable(Piwik_Common::getPathToPiwikRoot().'/themes/'); + $logoFilesExists = file_exists(Piwik_Common::getPathToPiwikRoot().'/themes/logo.png') && file_exists(Piwik_Common::getPathToPiwikRoot().'/themes/logo-header.png'); + $logoFilesWriteable = is_writeable(Piwik_Common::getPathToPiwikRoot().'/themes/logo.png') && is_writeable(Piwik_Common::getPathToPiwikRoot().'/themes/logo-header.png'); + + $view->logosWriteable = (($logoFilesExists && $logoFilesWriteable) || (!$logoFilesExists && $directoryWritable)); } $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser(); @@ -77,6 +90,11 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin $mail->encryption = Piwik_Common::getRequestVar('mailEncryption', ''); Zend_Registry::get('config')->mail = $mail->toArray(); + // update branding settings + $branding = Zend_Registry::get('config')->branding; + $branding->use_custom_logo = Piwik_Common::getRequestVar('useCustomLogo', '0'); + Zend_Registry::get('config')->branding = $branding->toArray(); + $toReturn = $response->getResponse(); } catch(Exception $e ) { $toReturn = $response->getResponseException( $e ); @@ -108,4 +126,38 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin : Piwik_LanguagesManager::getLanguageCodeForCurrentUser(); echo $view->render(); } + + 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'; + return; + } + echo '0'; + } } diff --git a/plugins/CoreAdminHome/templates/generalSettings.js b/plugins/CoreAdminHome/templates/generalSettings.js index fc5c49ce01..d1f29416a6 100644 --- a/plugins/CoreAdminHome/templates/generalSettings.js +++ b/plugins/CoreAdminHome/templates/generalSettings.js @@ -24,20 +24,38 @@ function getGeneralSettingsAJAX() request += '&mailUsername=' + $('#mailUsername').val(); request += '&mailPassword=' + $('#mailPassword').val(); request += '&mailEncryption=' + $('#mailEncryption').val(); + request += '&useCustomLogo=' + isCustomLogoEnabled(); ajaxRequest.data = request; return ajaxRequest; } function showSmtpSettings(value) { - $('#smtpSettings').toggle(value); + $('#smtpSettings').toggle(value==1); } function isSmtpEnabled() { return $('input[name="mailUseSmtp"]:checked').attr('value'); } +function showCustomLogoSettings(value) +{ + $('#logoSettings').toggle(value==1); +} +function isCustomLogoEnabled() +{ + return $('input[name="useCustomLogo"]:checked').attr('value'); +} + +function refreshCustomLogo() { + var imageDiv = $("#currentLogo"); + if(imageDiv && imageDiv.attr("src")) { + var logoUrl = imageDiv.attr("src").split("?")[0]; + imageDiv.attr("src", logoUrl+"?"+ (new Date()).getTime()); + } +} $(document).ready( function() { showSmtpSettings(isSmtpEnabled()); + showCustomLogoSettings(isCustomLogoEnabled()); $('#generalSettingsSubmit').click( function() { $.ajax( getGeneralSettingsAJAX() ); }); @@ -45,11 +63,31 @@ $(document).ready( function() { $('input[name=mailUseSmtp]').click(function(){ showSmtpSettings($(this).attr('value')); }); + $('input[name=useCustomLogo]').click(function(){ + refreshCustomLogo(); + showCustomLogoSettings($(this).attr('value')); + }); $('input').keypress( function(e) { var key=e.keyCode || e.which; if (key==13) { $('#generalSettingsSubmit').click(); } } - ) + ); + + $("#logoUploadForm").submit( function(data) { + var submittingForm = $( this ); + var frameName = "upload"+(new Date()).getTime(); + var uploadFrame = $("<iframe name=\""+frameName+"\" />"); + uploadFrame.css("display", "none"); + uploadFrame.load(function(data){ + setTimeout(function(){ + refreshCustomLogo(); + uploadFrame.remove();},1000); + }); + $("body:first").append(uploadFrame); + submittingForm.attr("target", frameName); + }); + + $('#customLogo').change(function(){$("#logoUploadForm").submit()}); }); diff --git a/plugins/CoreAdminHome/templates/generalSettings.tpl b/plugins/CoreAdminHome/templates/generalSettings.tpl index 797782b306..88adc3aca8 100644 --- a/plugins/CoreAdminHome/templates/generalSettings.tpl +++ b/plugins/CoreAdminHome/templates/generalSettings.tpl @@ -29,7 +29,7 @@ {'General_ArchivingInlineHelp'|translate}<br /> {'General_SeeTheOfficialDocumentationForMoreInformation'|translate:"<a href='?module=Proxy&action=redirect&url=http://piwik.org/docs/setup-auto-archiving/' target='_blank'>":"</a>"} {/capture} - {$browserArchivingHelp|inlineHelp} </td> + {$browserArchivingHelp|inlineHelp} </td> </tr> <tr> @@ -123,6 +123,41 @@ </table> </div> +<h2>{'CoreAdminHome_BrandingSettings'|translate}</h2> +<div id='brandSettings'> +<table class="adminTable" style='width:600px;'> + <tr> + <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> + </td> + </tr> +</table> +</div> +<div id='logoSettings'> + {capture assign=customLogoHelp} + {'CoreAdminHome_CustomLogoHelpText'|translate}<br /><br /> + {'CoreAdminHome_CustomLogoFeedbackInfo'|translate:"<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 style='width:200px'> + <input name="customLogo" type="file" id="customLogo" /><img src="themes/logo.png" id="currentLogo" /> + </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> + {/if} + </tr> + </table> + </form> +</div> + <input type="submit" value="{'General_Save'|translate}" id="generalSettingsSubmit" class="submit" /> <br /><br /> diff --git a/plugins/CoreAdminHome/templates/styles.css b/plugins/CoreAdminHome/templates/styles.css index 03d645b725..334bf5c2fe 100644 --- a/plugins/CoreAdminHome/templates/styles.css +++ b/plugins/CoreAdminHome/templates/styles.css @@ -126,6 +126,10 @@ table.admin tbody td:hover, table.admin tbody th:hover { width:100%; } +#logoSettings .ui-inline-help { + width:550px; +} + /* other styles */ .form-description { color:#666666; @@ -133,6 +137,6 @@ table.admin tbody td:hover, table.admin tbody th:hover { margin-left:10px; } -#smtpSettings { +#logoSettings, #smtpSettings { margin-left:50px; }
\ No newline at end of file diff --git a/plugins/CoreHome/templates/html_report_header.tpl b/plugins/CoreHome/templates/html_report_header.tpl index c4dc0870f3..ed94f2c671 100644 --- a/plugins/CoreHome/templates/html_report_header.tpl +++ b/plugins/CoreHome/templates/html_report_header.tpl @@ -5,7 +5,7 @@ <body style="color: rgb({$reportTextColor});"> <a name="reportTop"/> - <a target="_blank" href="{$currentPath}"><img title="{'General_GoTo'|translate:"Piwik"}" border="0" alt="Piwik" src='{$currentPath}themes/default/images/logo-header.png' /></a> + <a target="_blank" href="{$currentPath}"><img title="{'General_GoTo'|translate:"Piwik"}" border="0" alt="Piwik" src='{$logoHeader}' /></a> <h1 style="color: rgb({$reportTitleTextColor}); font-size: {$reportTitleTextSize}pt;"> {'General_Website'|translate} {$websiteName} diff --git a/plugins/CoreHome/templates/logo.tpl b/plugins/CoreHome/templates/logo.tpl index ecd43ec3d2..f22eb9c265 100644 --- a/plugins/CoreHome/templates/logo.tpl +++ b/plugins/CoreHome/templates/logo.tpl @@ -1,6 +1,6 @@ <span id="logo"> -<a href="index.php" title="Piwik # {'General_OpenSourceWebAnalytics'|translate}" style="text-decoration: none;"> - <img src='themes/default/images/logo-header.png' alt="Piwik" style='margin-left:10px' /> +<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> *} diff --git a/plugins/Login/Controller.php b/plugins/Login/Controller.php index c21eabc602..6b6919a784 100644 --- a/plugins/Login/Controller.php +++ b/plugins/Login/Controller.php @@ -75,6 +75,8 @@ class Piwik_Login_Controller extends Piwik_Controller */ private function configureView($view) { + $this->setBasicVariablesView($view); + $view->linkTitle = Piwik::getRandomTitle(); $view->enableFrames = Zend_Registry::get('config')->General->enable_framed_logins; diff --git a/plugins/Login/templates/header.tpl b/plugins/Login/templates/header.tpl index b292613fbd..338b9002fe 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='themes/default/images/logo.png' width='200' style='margin-right:20px'> + <img src='{$logo}' width='200' style='margin-right:20px'> <div class="description"># {$linkTitle}</div> </a> </div> |