diff options
32 files changed, 381 insertions, 299 deletions
@@ -1,15 +1,25 @@ +language selection test set wrong permission and trigger frontController:checkDir + why widgetize inherits Piwik_Widgetize_Controller we should call login->logout in installation->welcome instead of duplicating code fix images in sub tables change the loading widget red button with the standard blue loading widgetize should export the same format as currently seen: the callback to generate the embed code should be called when user clicks on icon below graph widgetize should work with clearspring: create a new iframe with an iframe + clearspring button -language selection separate all Core doc to Plugins and Users doc create ticket for wrong display seconds rss cache + user agent piwik +rename LogStats in Tracker +remove all instances of insert() and delete() and update() + +postEvent smarty doc is not clear, + feature we're not using (filter but what we need is simply way to print out html in templates from plugins) +1. The UI could be "security trimmed". So a normal user (a customer + in this case) should not see the "admin", "API" links ... +2. If the user is only allowed to see one website to analyze the + dropdown-control for other sites could be hidden. + to check ======== check that when online archiving disabled, take the last valid archiving diff --git a/config/global.ini.php b/config/global.ini.php index 4388887d20..8c3fd49dda 100755 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -16,14 +16,11 @@ adapter = PDO_MYSQL ; PDO_MYSQL or MYSQLI host = localhost username = root password = -dbname = piwik_tests +dbname = piwik_tests11 tables_prefix = piwiktests_ port = 3306 adapter = PDO_MYSQL -[Language] -current = en -fallback = en [Plugins] Plugins[] = CorePluginsAdmin @@ -31,6 +28,7 @@ Plugins[] = CoreAdminHome Plugins[] = CoreHome Plugins[] = API Plugins[] = Widgetize +Plugins[] = LanguagesManager Plugins[] = Actions Plugins[] = Dashboard Plugins[] = Referers @@ -94,6 +92,10 @@ enable_browser_archiving_triggering = true ; the page first-post in the subcategory development which belongs to the blog category action_category_delimiter = / +; if you want all your users to use Piwik in only one language, disable the LanguagesManager +; plugin, and set this default_language (users won't see the language drop down) +default_language = en + ; default sorting order used by all datatables (desc or asc) dataTable_default_sort_order = desc diff --git a/core/Common.php b/core/Common.php index f02c7abde0..1a7d84b50e 100644 --- a/core/Common.php +++ b/core/Common.php @@ -205,8 +205,7 @@ class Piwik_Common } } elseif( !is_null($value) - && !is_bool($value) - ) + && !is_bool($value)) { throw new Exception("The value to escape has not a supported type. Value = ".var_export($value, true)); } @@ -508,6 +507,21 @@ class Piwik_Common } /** + * Returns the browser language code, eg. "en-gb,en;q=0.5" + * + * @return string + */ + static public function getBrowserLanguage() + { + $browserLang = Piwik_Common::sanitizeInputValues(@$_SERVER['HTTP_ACCEPT_LANGUAGE']); + if(is_null($browserLang)) + { + $browserLang = ''; + } + return $browserLang; + } + + /** * Returns the visitor country based only on the Browser 'accepted language' information * * @param string $lang browser lang @@ -539,72 +553,74 @@ class Piwik_Common 'gb' => 'uk', ); - if(empty($lang) || strlen($lang) < 2) { return 'xx'; } - $lang = str_replace( array_keys($replaceLangCodeByCountryCode), - array_values($replaceLangCodeByCountryCode), - $lang - ); - + $browserLanguage = str_replace( + array_keys($replaceLangCodeByCountryCode), + array_values($replaceLangCodeByCountryCode), + $lang + ); + $validLanguages = array_keys($countryList); + return Piwik_Common::extractLanguageCodeFromBrowserLanguage($browserLanguage, $validLanguages); + } + + static public function extractLanguageCodeFromBrowserLanguage($browserLanguage, $validLanguages) + { // Ex: "fr" - if(strlen($lang) == 2) + if(strlen($browserLanguage) == 2) { - if(isset($countryList[$lang])) + if(in_array($browserLanguage, $validLanguages)) { - return $lang; + return $browserLanguage; } } // when comma - $offcomma = strpos($lang, ','); - + $offcomma = strpos($browserLanguage, ','); if($offcomma == 2) { // in 'fr,en-us', keep first two chars - $domain = substr($lang, 0, 2); - if(isset($countryList[$domain])) + $domain = substr($browserLanguage, 0, 2); + if(in_array($domain, $validLanguages)) { return $domain; } // catch the second language Ex: "fr" in "en,fr" - $domain = substr($lang, 3, 2); - if(isset($countryList[$domain])) + $domain = substr($browserLanguage, 3, 2); + if(in_array($domain, $validLanguages)) { return $domain; } } // detect second code Ex: "be" in "fr-be" - $off = strpos($lang, '-'); - if($off!==false) + $off = strpos($browserLanguage, '-'); + if($off !== false) { - $domain = substr($lang, $off+1, 2); - - if(isset($countryList[$domain])) + $domain = substr($browserLanguage, $off + 1, 2); + if(in_array($domain, $validLanguages)) { return $domain; } } // catch the second language Ex: "fr" in "en;q=1.0,fr;q=0.9" - if(preg_match("/^[a-z]{2};q=[01]\.[0-9],(?P<domain>[a-z]{2});/", $lang, $parts)) + if(preg_match("/^[a-z]{2};q=[01]\.[0-9],(?P<domain>[a-z]{2});/", $browserLanguage, $parts)) { $domain = $parts['domain']; - - if(isset($GLOBALS['countryList'][$domain][0])) + if(in_array($domain, $validLanguages)) { return $domain; } } // finally try with the first ever langage code - $domain = substr($lang, 0, 2); - if(isset($countryList[$domain])) + $domain = substr($browserLanguage, 0, 2); + if(in_array($domain, $validLanguages)) { return $domain; } @@ -613,7 +629,6 @@ class Piwik_Common return 'xx'; } - /** * Generate random string * diff --git a/core/Controller.php b/core/Controller.php index de1a1b2d53..9faa0fb817 100644 --- a/core/Controller.php +++ b/core/Controller.php @@ -213,7 +213,10 @@ abstract class Piwik_Controller try { $currentPeriod = Piwik_Common::getRequestVar('period'); - $view->idSite = Piwik_Common::getRequestVar('idSite'); + $idSite = Piwik_Common::getRequestVar('idSite'); + $view->idSite = $idSite; + $site = new Piwik_Site($idSite); + $view->siteName = $site->getName(); } catch(Exception $e) { self::redirectToIndex(Piwik::getModule(), Piwik::getAction()); } diff --git a/core/ErrorHandler.php b/core/ErrorHandler.php index a985e14e6e..3b7608d54f 100644 --- a/core/ErrorHandler.php +++ b/core/ErrorHandler.php @@ -33,10 +33,9 @@ function Piwik_ErrorHandler($errno, $errstr, $errfile, $errline) $backtrace = ob_get_contents(); ob_end_clean(); - try { Zend_Registry::get('logger_error')->log($errno, $errstr, $errfile, $errline, $backtrace); - }catch(Exception $e){ + } catch(Exception $e) { // in case the error occurs before the logger creation, we simply display it print("<pre>$errstr \nin '$errfile' at the line $errline\n\n$backtrace\n</pre>"); exit; diff --git a/core/FrontController.php b/core/FrontController.php index 0e51db1c7e..b93af2ab85 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -250,14 +250,17 @@ class Piwik_FrontController $exceptionToThrow = $e; } - Piwik::loadPlugins(); + Piwik_Translate::getInstance()->loadEnglishTranslation(); + $pluginsManager = Piwik_PluginsManager::getInstance(); + $pluginsManager->setPluginsToLoad( Zend_Registry::get('config')->Plugins->Plugins->toArray() ); + if($exceptionToThrow) { throw $exceptionToThrow; } Piwik::createDatabaseObject(); Piwik::createLogObject(); - Piwik::installLoadedPlugins(); + Piwik_PluginsManager::getInstance()->installLoadedPlugins(); Piwik::install(); Piwik_PostEvent('FrontController.initAuthenticationObject'); @@ -274,6 +277,10 @@ class Piwik_FrontController Zend_Registry::set('access', $access); Zend_Registry::get('access')->loadAccess(); + Piwik_Translate::getInstance()->loadUserTranslation(); + $pluginsManager->setLanguageToLoad( Piwik_Translate::getInstance()->getLanguageToLoad() ); + $pluginsManager->postLoadPlugins(); + Piwik::raiseMemoryLimitIfNecessary(); } catch(Exception $e) { Piwik_ExitWithMessage($e->getMessage()); diff --git a/core/LogStats/Visit.php b/core/LogStats/Visit.php index a148ab7d4c..78622f28f1 100644 --- a/core/LogStats/Visit.php +++ b/core/LogStats/Visit.php @@ -250,13 +250,8 @@ class Piwik_LogStats_Visit implements Piwik_LogStats_Visit_Interface $ip = Piwik_Common::getIp(); $ip = ip2long($ip); - $browserLang = substr(Piwik_Common::sanitizeInputValues(@$_SERVER['HTTP_ACCEPT_LANGUAGE']), 0, 20); - if(is_null($browserLang)) - { - $browserLang = ''; - } + $browserLang = substr(Piwik_Common::getBrowserLanguage(), 0, 20); - $configurationHash = $this->getConfigHash( $os, $browserName, diff --git a/core/Piwik.php b/core/Piwik.php index 9d1044dd41..8b4651c9b1 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -410,17 +410,6 @@ class Piwik return $title; } - static public function loadPlugins() - { - Piwik_PluginsManager::getInstance()->setLanguageToLoad( Piwik_Translate::getInstance()->getLanguageToLoad() ); - Piwik_PluginsManager::getInstance()->setPluginsToLoad( Zend_Registry::get('config')->Plugins->Plugins->toArray() ); - } - - static public function installLoadedPlugins() - { - Piwik_PluginsManager::getInstance()->installLoadedPlugins(); - } - static public function getTableCreateSql( $tableName ) { $tables = Piwik::getTablesCreateSql(); @@ -812,10 +801,9 @@ class Piwik static public function getTablesInstalled( $forceReload = true ) { - if(is_null(self::$tablesInstalled) + if(is_null(self::$tablesInstalled) || $forceReload === true) { - $db = Zend_Registry::get('db'); $config = Zend_Registry::get('config'); $prefixTables = $config->database->tables_prefix; @@ -830,7 +818,6 @@ class Piwik // at this point we have only the piwik tables which is good // but we still miss the piwik generated tables (using the class Piwik_TablePartitioning) - $allArchiveNumeric = $db->fetchCol("SHOW TABLES LIKE '".$prefixTables."archive_numeric%'"); $allArchiveBlob = $db->fetchCol("SHOW TABLES LIKE '".$prefixTables."archive_blob%'"); diff --git a/core/Plugin.php b/core/Plugin.php index a909d2ed2a..9d49a19a96 100644 --- a/core/Plugin.php +++ b/core/Plugin.php @@ -29,27 +29,7 @@ abstract class Piwik_Plugin * 'LogStatsPlugin' => bool // should we load this plugin during the stats logging process? */ abstract function getInformation(); - - /** - * Returns the plugin name - * @var string - */ - public function getName() - { - $info = $this->getInformation(); - return $info['name']; - } - - /** - * Returns the UserCountry part when the plugin class is Piwik_UserCountry - * - * @return string - */ - public function getClassName() - { - return substr(get_class($this), strlen("Piwik_")); - } - + /** * Returns the list of hooks registered with the methods names * @var array @@ -58,16 +38,7 @@ abstract class Piwik_Plugin { return array(); } - - /** - * Returns the names of the required plugins - * @var array - */ - public function getListRequiredPlugins() - { - return array(); - } - + /** * Executed after loading plugin and registering translations * Useful for code that uses translated strings from the plugin. @@ -98,5 +69,35 @@ abstract class Piwik_Plugin { return; } + + /** + * Returns the names of the required plugins + * @var array + */ + public function getListRequiredPlugins() + { + return array(); + } + + /** + * Returns the plugin name + * @var string + */ + public function getName() + { + $info = $this->getInformation(); + return $info['name']; + } + + /** + * Returns the UserCountry part when the plugin class is Piwik_UserCountry + * + * @return string + */ + public function getClassName() + { + return substr(get_class($this), strlen("Piwik_")); + } + } diff --git a/core/PluginsManager.php b/core/PluginsManager.php index 88fe7fca87..ad530cd65d 100644 --- a/core/PluginsManager.php +++ b/core/PluginsManager.php @@ -9,7 +9,6 @@ * @package Piwik */ - require_once "Plugin.php"; require_once "Event/Dispatcher.php"; @@ -106,32 +105,6 @@ class Piwik_PluginsManager } catch(Exception $e) {} } - /** - * TODO horrible dirty hack because the Config class is not clean enough. Needs to rewrite the Config - * __set and __get in a cleaner way, also see the __destruct which writes the configuration file. - * - * @return array - */ - protected function getInstalledPlugins() - { - if(!class_exists('Zend_Registry')) - { - throw new Exception("Not possible to list installed plugins (case LogStats module)"); - } - if(!is_null(Zend_Registry::get('config')->PluginsInstalled->PluginsInstalled)) - { - return Zend_Registry::get('config')->PluginsInstalled->PluginsInstalled->toArray(); - } - elseif(is_array(Zend_Registry::get('config')->PluginsInstalled)) - { - return Zend_Registry::get('config')->PluginsInstalled; - } - else - { - return Zend_Registry::get('config')->PluginsInstalled->toArray(); - } - } - public function installLoadedPlugins() { foreach($this->getLoadedPlugins() as $plugin) @@ -144,42 +117,6 @@ class Piwik_PluginsManager } } - protected function installPluginIfNecessary( Piwik_Plugin $plugin ) - { - $pluginName = $plugin->getClassName(); - - // is the plugin already installed or is it the first time we activate it? - $pluginsInstalled = $this->getInstalledPlugins(); - if(!in_array($pluginName,$pluginsInstalled)) - { - $this->installPlugin($plugin); - $pluginsInstalled[] = $pluginName; - Zend_Registry::get('config')->PluginsInstalled = $pluginsInstalled; - } - - $information = $plugin->getInformation(); - - // if the plugin is to be loaded during the statistics logging - if(isset($information['LogStatsPlugin']) - && $information['LogStatsPlugin'] === true) - { - $pluginsLogStats = Zend_Registry::get('config')->Plugins_LogStats->Plugins_LogStats; - if(is_null($pluginsLogStats)) - { - $pluginsLogStats = array(); - } - else - { - $pluginsLogStats = $pluginsLogStats->toArray(); - } - if(!in_array($pluginName, $pluginsLogStats)) - { - $pluginsLogStats[] = $pluginName; - Zend_Registry::get('config')->Plugins_LogStats = $pluginsLogStats; - } - } - } - public function activatePlugin($pluginName) { $plugins = Zend_Registry::get('config')->Plugins->Plugins->toArray(); @@ -227,15 +164,14 @@ class Piwik_PluginsManager $this->doLoadAlwaysActivatedPlugins = false; } - /** - * Add a plugin in the loaded plugins array - * - * @param string plugin name without prefix (eg. 'UserCountry') - * @param Piwik_Plugin $newPlugin - */ - protected function addLoadedPlugin( $pluginName, Piwik_Plugin $newPlugin ) + public function postLoadPlugins() { - $this->loadedPlugins[$pluginName] = $newPlugin; + $plugins = $this->getLoadedPlugins(); + foreach($plugins as $plugin) + { + $this->loadTranslation( $plugin, $this->languageToLoad ); + $plugin->postLoad(); + } } /** @@ -285,15 +221,13 @@ class Piwik_PluginsManager public function loadPlugins() { $this->pluginsToLoad = array_unique($this->pluginsToLoad); - - $pluginsToLoad = $this->pluginsToLoad; - + if($this->doLoadAlwaysActivatedPlugins) { - $pluginsToLoad = array_merge($this->pluginsToLoad, $this->pluginToAlwaysActivate); + $this->pluginsToLoad = array_merge($this->pluginsToLoad, $this->pluginToAlwaysActivate); } - foreach($pluginsToLoad as $pluginName) + foreach($this->pluginsToLoad as $pluginName) { $newPlugin = $this->loadPlugin($pluginName); @@ -302,11 +236,8 @@ class Piwik_PluginsManager if($this->doLoadPlugins && $this->isPluginActivated($pluginName)) { - $this->registerTranslation( $newPlugin, $this->languageToLoad ); $this->addPluginObservers( $newPlugin ); $this->addLoadedPlugin( $pluginName, $newPlugin); - - $newPlugin->postLoad(); } } } @@ -356,43 +287,12 @@ class Piwik_PluginsManager } return $newPlugin; } - - public function installPlugin( Piwik_Plugin $plugin ) - { - try{ - $plugin->install(); - } catch(Exception $e) { - throw new Piwik_Plugin_Exception($plugin->getName(), $e->getMessage()); } - } - public function installPlugins() - { - foreach($this->getLoadedPlugins() as $plugin) - { - try{ - $plugin->install(); - } catch(Exception $e) { - throw new Piwik_Plugin_Exception($plugin->getName(), $e->getMessage()); - } - } - } public function setLanguageToLoad( $code ) { $this->languageToLoad = $code; } - - /** - * For the given plugin, add all the observers of this plugin. - */ - private function addPluginObservers( Piwik_Plugin $plugin ) - { - $hooks = $plugin->getListHooksRegistered(); - - foreach($hooks as $hookName => $methodToCall) - { - $this->dispatcher->addObserver( array( $plugin, $methodToCall), $hookName ); - } - } + public function unloadPlugin( $plugin ) { if(!($plugin instanceof Piwik_Plugin )) @@ -420,12 +320,48 @@ class Piwik_PluginsManager $this->unloadPlugin($plugin); } } + + private function installPlugins() + { + foreach($this->getLoadedPlugins() as $plugin) + { + try{ + $plugin->install(); + } catch(Exception $e) { + throw new Piwik_Plugin_Exception($plugin->getName(), $e->getMessage()); + } + } + } + + /** + * For the given plugin, add all the observers of this plugin. + */ + private function addPluginObservers( Piwik_Plugin $plugin ) + { + $hooks = $plugin->getListHooksRegistered(); + + foreach($hooks as $hookName => $methodToCall) + { + $this->dispatcher->addObserver( array( $plugin, $methodToCall), $hookName ); + } + } + + /** + * Add a plugin in the loaded plugins array + * + * @param string plugin name without prefix (eg. 'UserCountry') + * @param Piwik_Plugin $newPlugin + */ + private function addLoadedPlugin( $pluginName, Piwik_Plugin $newPlugin ) + { + $this->loadedPlugins[$pluginName] = $newPlugin; + } /** * @param Piwik_Plugin $plugin * @param string $langCode */ - protected function registerTranslation( $plugin, $langCode ) + private function loadTranslation( $plugin, $langCode ) { // we are certainly in LogStats mode, Zend is not loaded if(!class_exists('Zend_Loader')) @@ -470,8 +406,76 @@ class Piwik_PluginsManager Piwik_Translate::getInstance()->addTranslationArray($translations); } -} + private function installPlugin( Piwik_Plugin $plugin ) + { + try{ + $plugin->install(); + } catch(Exception $e) { + throw new Piwik_Plugin_Exception($plugin->getName(), $e->getMessage()); } + } + + /** + * TODO horrible dirty hack because the Config class is not clean enough. Needs to rewrite the Config + * __set and __get in a cleaner way, also see the __destruct which writes the configuration file. + * + * @return array + */ + private function getInstalledPlugins() + { + if(!class_exists('Zend_Registry')) + { + throw new Exception("Not possible to list installed plugins (case LogStats module)"); + } + if(!is_null(Zend_Registry::get('config')->PluginsInstalled->PluginsInstalled)) + { + return Zend_Registry::get('config')->PluginsInstalled->PluginsInstalled->toArray(); + } + elseif(is_array(Zend_Registry::get('config')->PluginsInstalled)) + { + return Zend_Registry::get('config')->PluginsInstalled; + } + else + { + return Zend_Registry::get('config')->PluginsInstalled->toArray(); + } + } + private function installPluginIfNecessary( Piwik_Plugin $plugin ) + { + $pluginName = $plugin->getClassName(); + + // is the plugin already installed or is it the first time we activate it? + $pluginsInstalled = $this->getInstalledPlugins(); + if(!in_array($pluginName,$pluginsInstalled)) + { + $this->installPlugin($plugin); + $pluginsInstalled[] = $pluginName; + Zend_Registry::get('config')->PluginsInstalled = $pluginsInstalled; + } + + $information = $plugin->getInformation(); + + // if the plugin is to be loaded during the statistics logging + if(isset($information['LogStatsPlugin']) + && $information['LogStatsPlugin'] === true) + { + $pluginsLogStats = Zend_Registry::get('config')->Plugins_LogStats->Plugins_LogStats; + if(is_null($pluginsLogStats)) + { + $pluginsLogStats = array(); + } + else + { + $pluginsLogStats = $pluginsLogStats->toArray(); + } + if(!in_array($pluginName, $pluginsLogStats)) + { + $pluginsLogStats[] = $pluginName; + Zend_Registry::get('config')->Plugins_LogStats = $pluginsLogStats; + } + } + } +} class Piwik_Plugin_Exception extends Exception { @@ -484,7 +488,6 @@ class Piwik_Plugin_Exception extends Exception } } - /** * Post an event to the dispatcher which will notice the observers */ @@ -499,4 +502,4 @@ function Piwik_PostEvent( $eventName, &$object = null, $info = array() ) function Piwik_AddAction( $hookName, $function ) { Piwik_PluginsManager::getInstance()->dispatcher->addObserver( $function, $hookName ); -}
\ No newline at end of file +} diff --git a/core/Site.php b/core/Site.php index 12370dde65..d9001b6393 100644 --- a/core/Site.php +++ b/core/Site.php @@ -28,10 +28,12 @@ class Piwik_Site self::$infoSites[$this->id] = Piwik_SitesManager_API::getSiteFromId($idsite); } } + function getName() { return self::$infoSites[$this->id]['name']; } + function getMainUrl() { return self::$infoSites[$this->id]['main_url']; diff --git a/core/TablePartitioning.php b/core/TablePartitioning.php index eda912f995..328da71736 100644 --- a/core/TablePartitioning.php +++ b/core/TablePartitioning.php @@ -31,14 +31,13 @@ abstract class Piwik_TablePartitioning abstract protected function generateTableName() ; - public function setTimestamp( $timestamp ) { $this->timestamp = $timestamp; $this->generatedTableName = null; $this->getTableName(); } - + public function getTableName() { // table name already processed diff --git a/core/Translate.php b/core/Translate.php index 7f4ea56583..a2d5f92af5 100644 --- a/core/Translate.php +++ b/core/Translate.php @@ -15,10 +15,9 @@ class Piwik_Translate { static private $instance = null; + private $englishLanguageLoaded = false; /** - * Returns singleton - * * @return Piwik_Translate */ static public function getInstance() @@ -30,20 +29,27 @@ class Piwik_Translate } return self::$instance; } - - private function __construct() + + public function loadEnglishTranslation() { - $translations = array(); - - $language = $this->getFallbackLanguageToLoad(); - require_once "lang/" . $language .".php"; + require "lang/en.php"; $this->addTranslationArray($translations); - + $this->setLocale(); + $this->englishLanguageLoaded = true; + } + + public function loadUserTranslation() + { $language = $this->getLanguageToLoad(); - require_once "lang/" . $language .".php"; - $this->addTranslationArray($translations); + if($language === 'en' + && $this->englishLanguageLoaded) + { + return; + } - setlocale(LC_ALL, $GLOBALS['Piwik_translations']['General_Locale']); + require "lang/" . $language . ".php"; + $this->addTranslationArray($translations); + $this->setLocale(); } public function addTranslationArray($translation) @@ -57,13 +63,18 @@ class Piwik_Translate } /** - * @return string the language filename prefix, eg "en" for english - * @throws exception if the language set in the config file is not a valid filename + * @return string the language filename prefix, eg 'en' for english + * @throws exception if the language set is not a valid filename */ public function getLanguageToLoad() { - $language = Zend_Registry::get('config')->Language->current; + $language = null; + Piwik_PostEvent('Translate.getLanguageToLoad', $language); + if(is_null($language)) + { + $language = Zend_Registry::get('config')->General->default_language; + } if( Piwik_Common::isValidFilename($language)) { return $language; @@ -74,20 +85,14 @@ class Piwik_Translate } } - protected function getFallbackLanguageToLoad() - { - return Zend_Registry::get('config')->Language->fallback; - } - /** * Generate javascript translations array * * @return string containing javascript code with translations array (including <script> tag) - * */ - public function getJavascriptTranslations($moduleList) + public function getJavascriptTranslations(array $moduleList) { - if( !$moduleList ) + if( empty($moduleList) ) { return ''; } @@ -123,6 +128,11 @@ class Piwik_Translate return $js; } + + private function setLocale() + { + setlocale(LC_ALL, $GLOBALS['Piwik_translations']['General_Locale']); + } } function Piwik_Translate($index) diff --git a/core/Url.php b/core/Url.php index f6ece7c37d..f0279fc2e3 100644 --- a/core/Url.php +++ b/core/Url.php @@ -44,6 +44,16 @@ class Piwik_Url } } + static public function redirectToReferer() + { + $referer = self::getReferer(); + if($referer !== false) + { + self::redirectToUrl($referer); + } + self::redirectToUrl(Piwik_URL::getCurrentUrlWithoutQueryString()); + } + static public function redirectToUrl( $url ) { header("Location: $url"); diff --git a/core/ViewDataTable/GenerateGraphData.php b/core/ViewDataTable/GenerateGraphData.php index 6174dbba9c..53ee435ddd 100644 --- a/core/ViewDataTable/GenerateGraphData.php +++ b/core/ViewDataTable/GenerateGraphData.php @@ -48,7 +48,7 @@ abstract class Piwik_ViewDataTable_GenerateGraphData extends Piwik_ViewDataTable * * @var int */ - protected $graphLimit = 5; + protected $graphLimit = 6; /** * Sets the number max of elements to display (number of pie slice, vertical bars, etc.) diff --git a/core/Visualization/Chart.php b/core/Visualization/Chart.php index 6e58ba721f..a80ac489db 100644 --- a/core/Visualization/Chart.php +++ b/core/Visualization/Chart.php @@ -10,7 +10,6 @@ */ require_once "Visualization/OpenFlashChart.php"; - /** * Generates the data in the Open Flash Chart format, from the given data. * Uses Open flash chart PHP library @see Piwik_Visualization_OpenFlashChart diff --git a/lang/de.php b/lang/de.php index 332505a4b4..325307d1f9 100644 --- a/lang/de.php +++ b/lang/de.php @@ -3,7 +3,7 @@ $translations = array( 'General_Locale' => 'de_DE.UTF-8', 'General_TranslatorName' => 'Frank Bueltge', 'General_TranslatorEmail' => 'frank@bueltge.de', - 'General_EnglishLanguageName' => 'English', + 'General_EnglishLanguageName' => 'German', 'General_OriginalLanguageName' => 'Deutsch', 'General_Unknown' => 'unbekannt', 'General_Required' => '%s benötigt', diff --git a/lang/nl.php b/lang/nl.php index 67bcff1266..6a0e3ad840 100644 --- a/lang/nl.php +++ b/lang/nl.php @@ -3,8 +3,8 @@ $translations = array( 'General_Locale' => 'nl_NL.UTF-8', 'General_TranslatorName' => 'wicliff wolda', 'General_TranslatorEmail' => 'webmaster@bloody-wicked.com', - 'General_EnglishLanguageName' => 'Engels', - 'General_OriginalLanguageName' => 'Engels', + 'General_EnglishLanguageName' => 'Dutch', + 'General_OriginalLanguageName' => 'Nederlands', 'General_Unknown' => 'Onbekend', 'General_Required' => 'verplicht', 'General_Error' => 'fout', diff --git a/plugins/CoreAdminHome/templates/header.tpl b/plugins/CoreAdminHome/templates/header.tpl index 4b3a4b0df6..ccc4d9d125 100644 --- a/plugins/CoreAdminHome/templates/header.tpl +++ b/plugins/CoreAdminHome/templates/header.tpl @@ -10,12 +10,16 @@ <script type="text/javascript" src="libs/jquery/jquery.blockUI.js"></script> <script type="text/javascript" src="themes/default/common.js"></script> <script type="text/javascript" src="libs/jquery/thickbox.js"></script> +<script type="text/javascript" src="libs/javascript/sprintf.js"></script> <link rel="stylesheet" type="text/css" href="libs/jquery/thickbox.css" /> <link rel="stylesheet" type="text/css" href="themes/default/common.css" /> <link rel="stylesheet" type="text/css" href="themes/default/styles.css"> <link rel="stylesheet" type="text/css" href="plugins/CoreAdminHome/templates/styles.css" /> +{postEvent name="template_js_import"} +{postEvent name="template_css_import"} + {include file="CoreHome/templates/top_bar.tpl"} <div id="header"> diff --git a/plugins/CoreHome/templates/js_css_includes.tpl b/plugins/CoreHome/templates/js_css_includes.tpl index 90b0111faf..bede66bdcc 100644 --- a/plugins/CoreHome/templates/js_css_includes.tpl +++ b/plugins/CoreHome/templates/js_css_includes.tpl @@ -26,3 +26,5 @@ <link rel="stylesheet" type="text/css" href="plugins/Dashboard/templates/dashboard.css" /> <link rel="stylesheet" type="text/css" href="libs/jquery/jquery-calendar.css" /> +{postEvent name="template_js_import"} +{postEvent name="template_css_import"} diff --git a/plugins/CoreHome/templates/menu.css b/plugins/CoreHome/templates/menu.css index 00baa61df0..53ed20ee40 100644 --- a/plugins/CoreHome/templates/menu.css +++ b/plugins/CoreHome/templates/menu.css @@ -4,6 +4,7 @@ } .nav { + z-index:10; padding-bottom: 2.5em; height: 2.5em; float: left; diff --git a/plugins/CoreHome/templates/sites_select.tpl b/plugins/CoreHome/templates/sites_select.tpl deleted file mode 100644 index e69de29bb2..0000000000 --- a/plugins/CoreHome/templates/sites_select.tpl +++ /dev/null diff --git a/plugins/CoreHome/templates/sites_selection.tpl b/plugins/CoreHome/templates/sites_selection.tpl index 57287a35bd..753ed724f4 100644 --- a/plugins/CoreHome/templates/sites_selection.tpl +++ b/plugins/CoreHome/templates/sites_selection.tpl @@ -1,9 +1,28 @@ -<span id="sitesSelection">Site <select name="idSite" onchange='javascript:this.form.submit()'> - <optgroup label="Sites"> - {foreach from=$sites item=info} - <option label="{$info.name}" value="{$info.idsite}" {if $idSite==$info.idsite} selected="selected"{/if}>{$info.name}</option> - {/foreach} - </optgroup> -</select> -{hiddenurl idSite=null} +<span id="sitesSelectionWrapper" > + <span id="selectedSiteName" style="display:none">{$siteName}</span> + <span id="sitesSelection" style="position:absolute">Site + <form action="{url idSite=null}" method="get"> + <select name="idSite"> + {foreach from=$sites item=info} + <option value="{$info.idsite}" {if $idSite==$info.idsite} selected="selected"{/if}>{$info.name}</option> + {/foreach} + </select> + {hiddenurl idSite=null} + <input type="submit" value="go"/> + </form> + </span> + + {literal}<script language="javascript"> + $(document).ready(function() { + var extraPadding = 0; + // if there is only one website, we dont show the arrows image, so no need to add the extra padding + if( $('#sitesSelection').find('option').size() > 1) + { + extraPadding = 21; + } + var widthSitesSelection = $("#selectedSiteName").width() + 4 + extraPadding; + $("#sitesSelectionWrapper").css('padding-right', widthSitesSelection); + $("#sitesSelection").fdd2div({CssClassName:"formDiv"}); + });</script> + {/literal} </span>
\ No newline at end of file diff --git a/plugins/CoreHome/templates/top_bar.tpl b/plugins/CoreHome/templates/top_bar.tpl index 1d01ccf8ba..d764cbc7f9 100644 --- a/plugins/CoreHome/templates/top_bar.tpl +++ b/plugins/CoreHome/templates/top_bar.tpl @@ -1,21 +1,21 @@ {assignTopBar}
+
<div id="topLeftBar">
{foreach from=$topBarElements item=element}
- <span class="topBarElem">{if $element.0 == $currentModule}<b>{else}<a href="{$element.2|@urlRewriteWithParameters}" {if isset($element.3)}{$element.3}{/if}>{/if}{$element.1}{if $element.0 == $currentModule}</b>{else}</a>{/if}
- </span>
+ <span class="topBarElem">{if $element.0 == $currentModule}<b>{else}<a href="{$element.2|@urlRewriteWithParameters}" {if isset($element.3)}{$element.3}{/if}>{/if}{$element.1}{if $element.0 == $currentModule}</b>{else}</a>{/if}</span>
{/foreach}
+{postEvent name="template_topBar"}
</div>
<div id="topRightBar">
<nobr>
-<form action="{url idSite=null}" method="get">
<small>
- <strong>{$userLogin}</strong>
-| <a href='?module=CoreAdminHome'>Admin</a>
-{if $showSitesSelection}| {include file=CoreHome/templates/sites_selection.tpl}{/if}
+<strong>{$userLogin}</strong>
+| <a href='?module=CoreAdminHome'>Admin</a>
+ {if $showSitesSelection}| {include file=CoreHome/templates/sites_selection.tpl}{/if}
| {if $userLogin == 'anonymous'}<a href='?module=Login'>{'Login_LogIn'|translate}</a>{else}<a href='?module=Login&action=logout'>{'Login_Logout'|translate}</a>{/if}
</small>
-</form>
+
</nobr>
</div>
diff --git a/plugins/ExampleRssWidget/ExampleRssWidget.php b/plugins/ExampleRssWidget/ExampleRssWidget.php index bcff37ddb7..da3745ce41 100644 --- a/plugins/ExampleRssWidget/ExampleRssWidget.php +++ b/plugins/ExampleRssWidget/ExampleRssWidget.php @@ -12,6 +12,16 @@ class Piwik_ExampleRssWidget extends Piwik_Plugin 'version' => '0.1', ); } + + public function getListHooksRegistered() + { + return array( 'template_css_import' => 'css'); + } + + function css() + { + echo '<link rel="stylesheet" type="text/css" href="plugins/ExampleRssWidget/styles.css" />'; + } } Piwik_AddWidget('ExampleRssWidget', 'rssPiwik', 'Piwik.org Blog'); @@ -28,7 +38,6 @@ class Piwik_ExampleRssWidget_Controller extends Piwik_Controller exit; } - echo $this->css(); echo '<div style="padding:10px 15px;"><ul class="rss">'; $i = 0; @@ -50,40 +59,4 @@ class Piwik_ExampleRssWidget_Controller extends Piwik_Controller echo '</ul></div>'; } - function css() - { - return "<style> - .rss ul { - list-style-image:none; - list-style-position:outside; - list-style-type:none; - padding:0pt; - } - .rss li { - line-height:140%; - margin-bottom:6px; - margin:0.5em 0pt 1em; - } - .rss-title, .rss-date { - float:left; - font-size:14px; - line-height:140%; - } - .rss-title{ - color:#2583AD; - margin:0pt 0.5em 0.2em 0pt; - font-weight:bold; - } - .rss-date { - color:#999999; - margin:0pt; - } - .rss-description { - clear:both; - line-height:1.5em; - font-size:11px; - color:#333333; - } - </style>"; - } }
\ No newline at end of file diff --git a/plugins/ExampleRssWidget/styles.css b/plugins/ExampleRssWidget/styles.css new file mode 100644 index 0000000000..c0c284c60b --- /dev/null +++ b/plugins/ExampleRssWidget/styles.css @@ -0,0 +1,31 @@ +.rss ul { + list-style-image:none; + list-style-position:outside; + list-style-type:none; + padding:0pt; +} +.rss li { + line-height:140%; + margin-bottom:6px; + margin:0.5em 0pt 1em; +} +.rss-title, .rss-date { + float:left; + font-size:14px; + line-height:140%; +} +.rss-title{ + color:#2583AD; + margin:0pt 0.5em 0.2em 0pt; + font-weight:bold; +} +.rss-date { + color:#999999; + margin:0pt; +} +.rss-description { + clear:both; + line-height:1.5em; + font-size:11px; + color:#333333; +}
\ No newline at end of file diff --git a/plugins/Feedback/index.tpl b/plugins/Feedback/index.tpl index 454404f284..7cc06f9fd2 100644 --- a/plugins/Feedback/index.tpl +++ b/plugins/Feedback/index.tpl @@ -14,9 +14,9 @@ input { <form method="post" action="?module=Feedback&action=sendFeedback">
<p><strong>your email :</strong>
-<br /><input type="text" name="email" size="47" /></p>
+<br /><input type="text" name="email" size="40" /></p>
<p><strong>your feedback:</strong><br/>
<i>please be precise if you request for a feature or report a bug</i></p>
-<textarea name="body" cols="45" rows="10"></textarea>
+<textarea name="body" cols="37" rows="10"></textarea>
<input type="submit" value="Send feedback" />
</form>
diff --git a/plugins/Installation/templates/systemCheck.tpl b/plugins/Installation/templates/systemCheck.tpl index 6626ff1892..72d80e4dd2 100644 --- a/plugins/Installation/templates/systemCheck.tpl +++ b/plugins/Installation/templates/systemCheck.tpl @@ -86,17 +86,29 @@ <td>{if $infos.mail_ok}{$ok}{else}{$warning}{/if}</td>
</tr>
</table>
-<p><small>
-Legend:
+
+
+{if !$showNextStep}
+{literal}
+<style>
+#legend {
+ border:1px solid #A5A5A5;
+ padding:5px;
+ color:#727272;
+ margin-top:30px;
+}
+</style>
+{/literal}
+<div id="legend"><small>
+<b>Legend</b>
<br />
{$ok} {'General_Ok'|translate}<br />
{$error} {'General_Error'|translate}: {'Installation_SystemCheckError'|translate} <br />
{$warning} {'General_Warning'|translate}: {'Installation_SystemCheckWarning'|translate} <br />
-</small></p>
+</small></div>
+
-{if !$showNextStep}
<p class="nextStep">
<a href="{url}">{'General_Refresh'|translate} »</a>
</p>
-
{/if}
diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php index f498d83d8b..d920986ca5 100644 --- a/plugins/Provider/Provider.php +++ b/plugins/Provider/Provider.php @@ -167,6 +167,7 @@ class Piwik_Provider extends Piwik_Plugin $out =& $notification->getNotificationObject(); $out = '<div id="leftcolumn">'; } + public function footerUserCountry($notification) { $out =& $notification->getNotificationObject(); @@ -177,4 +178,3 @@ class Piwik_Provider extends Piwik_Plugin $out .= '</div>'; } } - diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php index 966b4134ed..014d2eda44 100644 --- a/plugins/VisitTime/VisitTime.php +++ b/plugins/VisitTime/VisitTime.php @@ -57,6 +57,7 @@ class Piwik_VisitTime extends Piwik_Plugin $archiveProcessing->archiveDataTable($dataTableToSum); } + public function archiveDay( $notification ) { $archiveProcessing = $notification->getNotificationObject(); diff --git a/plugins/Widgetize/templates/index.tpl b/plugins/Widgetize/templates/index.tpl index 5a4af63a07..4d452fbf46 100644 --- a/plugins/Widgetize/templates/index.tpl +++ b/plugins/Widgetize/templates/index.tpl @@ -30,9 +30,6 @@ .menu { display: inline; } -.previewDiv { - height: auto; -} .formEmbedCode{ font-size: 11px; text-decoration: none; @@ -72,7 +69,7 @@ If you want your widgets to be viewable by everybody, you first have to set the </div> <div class="subMenu" id="sub3"> <div class="widget"> - <div class="widgetDiv previewDiv" id="widgetId">Widget here + <div class="widgetDiv previewDiv">Widget here </div> </div> <div id='embedThisWidget'></div> diff --git a/themes/default/common.css b/themes/default/common.css index 1da1fd38e9..9041f124fe 100644 --- a/themes/default/common.css +++ b/themes/default/common.css @@ -9,7 +9,7 @@ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abb vertical-align: baseline; background: transparent; } - +form {margin: 0px 0px 0px 0px; } body { line-height: 1.33; background-color: white; |