diff options
-rw-r--r-- | core/Common.php | 3 | ||||
-rw-r--r-- | core/Option.php | 2 | ||||
-rw-r--r-- | core/PluginsManager.php | 9 | ||||
-rw-r--r-- | core/ViewDataTable.php | 1 | ||||
-rw-r--r-- | plugins/Installation/Controller.php | 1 | ||||
-rw-r--r-- | plugins/Installation/Installation.php | 3 | ||||
-rw-r--r-- | plugins/LanguagesManager/LanguagesManager.php | 3 | ||||
-rw-r--r-- | plugins/Login/Auth.php | 1 | ||||
-rw-r--r-- | plugins/Login/Login.php | 2 | ||||
-rw-r--r-- | plugins/UserCountry/API.php | 1 | ||||
-rw-r--r-- | plugins/UserCountry/Controller.php | 57 | ||||
-rw-r--r-- | plugins/UserCountry/UserCountry.php | 90 | ||||
-rw-r--r-- | plugins/UserCountry/functions.php | 34 | ||||
-rw-r--r-- | plugins/UserSettings/UserSettings.php | 4 |
14 files changed, 102 insertions, 109 deletions
diff --git a/core/Common.php b/core/Common.php index 4c188e9595..2cca73ce91 100644 --- a/core/Common.php +++ b/core/Common.php @@ -157,8 +157,9 @@ class Piwik_Common */ static public function isValidFilename($filename) { - return (false !== ereg("(^[a-zA-Z0-9]+([a-zA-Z\_0-9\.-]*))$" , $filename)); + return (0 !== preg_match("/(^[a-zA-Z0-9]+([a-zA-Z\_0-9\.-]*))$/" , $filename)); } + /** * Returns true if the string passed may be a URL. * We don't need a precise test here because the value comes from the website diff --git a/core/Option.php b/core/Option.php index 95483998c1..f049dcebcf 100644 --- a/core/Option.php +++ b/core/Option.php @@ -63,7 +63,7 @@ class Piwik_Option } catch(Exception $e) { // this would fail for users who upgraded between 0.2.10 and 0.2.13 where option table didn't have the autoload field yet } - foreach($this->all as $option) + foreach($all as $option) { $this->all[$option['option_name']] = $option['option_value']; } diff --git a/core/PluginsManager.php b/core/PluginsManager.php index 09dcc6571f..60c4f42f7a 100644 --- a/core/PluginsManager.php +++ b/core/PluginsManager.php @@ -262,15 +262,6 @@ class Piwik_PluginsManager $path = 'plugins/' . $pluginFileName; - // case Tracker, we don't throw the exception, we don't want to add the Zend overhead - if(class_exists('Zend_Loader') - && !Zend_Loader::isReadable($path)) - { - throw new Exception("<b>The plugin file {$path} couldn't be found. </b><br> - If you are updating from a 0.2.x version, please <a target=_blank href='http://piwik.org/faq/update/#faq_6'>read the FAQ</a>!<br> - Found in your config/config.ini.php file:<br><code>[Plugins]</code><br><code>Plugins[] = $pluginName;</code>"); - } - require_once $path; if(!class_exists($pluginClassName)) diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php index 224e627e60..3e5c78aa0d 100644 --- a/core/ViewDataTable.php +++ b/core/ViewDataTable.php @@ -10,6 +10,7 @@ */ require_once "API/Request.php"; +require_once "View.php"; /** * This class is used to load (from the API) and customize the output of a given DataTable. diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php index fc957f0bbd..81f80c2070 100644 --- a/plugins/Installation/Controller.php +++ b/plugins/Installation/Controller.php @@ -9,7 +9,6 @@ * @package Piwik_Installation
*/
-require_once "View.php";
require_once "Installation/View.php";
/**
diff --git a/plugins/Installation/Installation.php b/plugins/Installation/Installation.php index bb7d32df4f..6e89eeefa3 100644 --- a/plugins/Installation/Installation.php +++ b/plugins/Installation/Installation.php @@ -10,8 +10,6 @@ */ -require_once "Installation/Controller.php"; - /** * * @package Piwik_Installation @@ -48,6 +46,7 @@ class Piwik_Installation extends Piwik_Plugin protected function getInstallationController() { + require_once "Installation/Controller.php"; return new $this->installationControllerName(); } diff --git a/plugins/LanguagesManager/LanguagesManager.php b/plugins/LanguagesManager/LanguagesManager.php index 852b6fe7c1..401300520e 100644 --- a/plugins/LanguagesManager/LanguagesManager.php +++ b/plugins/LanguagesManager/LanguagesManager.php @@ -9,8 +9,6 @@ * @package Piwik_LanguageManager */ -require_once "LanguagesManager/API.php"; - class Piwik_LanguagesManager extends Piwik_Plugin { public function getInformation() @@ -49,6 +47,7 @@ class Piwik_LanguagesManager extends Piwik_Plugin function getLanguageToLoad($notification) { + require_once "LanguagesManager/API.php"; $language =& $notification->getNotificationObject(); $language = self::getLanguageCodeForCurrentUser(); } diff --git a/plugins/Login/Auth.php b/plugins/Login/Auth.php index 2ad17e784a..72cc0460d7 100644 --- a/plugins/Login/Auth.php +++ b/plugins/Login/Auth.php @@ -1,4 +1,5 @@ <?php +require_once "UsersManager/API.php"; /** * @package Piwik */ diff --git a/plugins/Login/Login.php b/plugins/Login/Login.php index 91cb94d52a..a6aad5cbba 100644 --- a/plugins/Login/Login.php +++ b/plugins/Login/Login.php @@ -8,7 +8,6 @@ * * @package Piwik_Login */ -require "Login/Controller.php"; require "Login/Auth.php"; require "Cookie.php"; @@ -45,6 +44,7 @@ class Piwik_Login extends Piwik_Plugin $exception = $notification->getNotificationObject(); $exceptionMessage = $exception->getMessage(); + require "Login/Controller.php"; $controller = new Piwik_Login_Controller; $controller->login($exceptionMessage); } diff --git a/plugins/UserCountry/API.php b/plugins/UserCountry/API.php index 194310d4ed..404dc0cbc4 100644 --- a/plugins/UserCountry/API.php +++ b/plugins/UserCountry/API.php @@ -9,6 +9,7 @@ * @package Piwik_UserCountry */ require_once "DataFiles/Countries.php"; +require_once "UserCountry/functions.php"; /** * diff --git a/plugins/UserCountry/Controller.php b/plugins/UserCountry/Controller.php new file mode 100644 index 0000000000..29e7f56b07 --- /dev/null +++ b/plugins/UserCountry/Controller.php @@ -0,0 +1,57 @@ +<?php +require_once "ViewDataTable.php"; + +class Piwik_UserCountry_Controller extends Piwik_Controller +{ + function index() + { + $view = new Piwik_View('UserCountry/index.tpl'); + + $view->urlSparklineCountries = $this->getUrlSparkline('getLastDistinctCountriesGraph'); + $view->numberDistinctCountries = $this->getNumberOfDistinctCountries(true); + + $view->dataTableCountry = $this->getCountry(true); + $view->dataTableContinent = $this->getContinent(true); + + echo $view->render(); + } + + function getCountry( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(); + $view->init( 'UserCountry', __FUNCTION__, "UserCountry.getCountry" ); + $view->disableExcludeLowPopulation(); + + $view->setColumnsToDisplay( array('label','nb_uniq_visitors') ); + $view->setSortedColumn( 1 ); + $view->disableSearchBox(); + $view->setLimit( 5 ); + + return $this->renderView($view, $fetch); + } + + function getNumberOfDistinctCountries( $fetch = false) + { + return $this->getNumericValue('UserCountry.getNumberOfDistinctCountries'); + } + + function getLastDistinctCountriesGraph( $fetch = false ) + { + $view = $this->getLastUnitGraph('UserCountry',__FUNCTION__, "UserCountry.getNumberOfDistinctCountries"); + return $this->renderView($view, $fetch); + } + + function getContinent( $fetch = false) + { + $view = Piwik_ViewDataTable::factory( 'graphVerticalBar' ); + $view->init( 'UserCountry', __FUNCTION__, "UserCountry.getContinent" ); + $view->disableExcludeLowPopulation(); + $view->disableSearchBox(); + $view->disableOffsetInformation(); + $view->disableSort(); + $view->setColumnsToDisplay( array('label','nb_uniq_visitors') ); + $view->setSortedColumn( 1 ); + + return $this->renderView($view, $fetch); + } +} diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php index 75b9b3084e..bd69f64067 100644 --- a/plugins/UserCountry/UserCountry.php +++ b/plugins/UserCountry/UserCountry.php @@ -82,93 +82,3 @@ class Piwik_UserCountry extends Piwik_Plugin } } -require_once "ViewDataTable.php"; - -class Piwik_UserCountry_Controller extends Piwik_Controller -{ - function index() - { - $view = new Piwik_View('UserCountry/index.tpl'); - - $view->urlSparklineCountries = $this->getUrlSparkline('getLastDistinctCountriesGraph'); - $view->numberDistinctCountries = $this->getNumberOfDistinctCountries(true); - - $view->dataTableCountry = $this->getCountry(true); - $view->dataTableContinent = $this->getContinent(true); - - echo $view->render(); - } - - function getCountry( $fetch = false) - { - $view = Piwik_ViewDataTable::factory(); - $view->init( 'UserCountry', __FUNCTION__, "UserCountry.getCountry" ); - $view->disableExcludeLowPopulation(); - - $view->setColumnsToDisplay( array('label','nb_uniq_visitors') ); - $view->setSortedColumn( 1 ); - $view->disableSearchBox(); - $view->setLimit( 5 ); - - return $this->renderView($view, $fetch); - } - - function getNumberOfDistinctCountries( $fetch = false) - { - return $this->getNumericValue('UserCountry.getNumberOfDistinctCountries'); - } - - function getLastDistinctCountriesGraph( $fetch = false ) - { - $view = $this->getLastUnitGraph('UserCountry',__FUNCTION__, "UserCountry.getNumberOfDistinctCountries"); - return $this->renderView($view, $fetch); - } - - function getContinent( $fetch = false) - { - $view = Piwik_ViewDataTable::factory( 'graphVerticalBar' ); - $view->init( 'UserCountry', __FUNCTION__, "UserCountry.getContinent" ); - $view->disableExcludeLowPopulation(); - $view->disableSearchBox(); - $view->disableOffsetInformation(); - $view->disableSort(); - $view->setColumnsToDisplay( array('label','nb_uniq_visitors') ); - $view->setSortedColumn( 1 ); - - return $this->renderView($view, $fetch); - } -} - - -function Piwik_getFlagFromCode($code) -{ - $path = 'plugins/UserCountry/flags/%s.png'; - - $normalPath = sprintf($path,$code); - - // flags not in the package ! - if(!file_exists($normalPath)) - { - return sprintf($path, 'xx'); - } - return $normalPath; -} - -function Piwik_ContinentTranslate($label) -{ - if($label == 'unk') - { - return Piwik_Translate('General_Unknown'); - } - - return Piwik_Translate('UserCountry_continent_'. $label); -} - -function Piwik_CountryTranslate($label) -{ - if($label == 'xx') - { - return Piwik_Translate('General_Unknown'); - } - return Piwik_Translate('UserCountry_country_'. $label); -} diff --git a/plugins/UserCountry/functions.php b/plugins/UserCountry/functions.php new file mode 100644 index 0000000000..e6bc371649 --- /dev/null +++ b/plugins/UserCountry/functions.php @@ -0,0 +1,34 @@ +<?php + +function Piwik_getFlagFromCode($code) +{ + $path = 'plugins/UserCountry/flags/%s.png'; + + $normalPath = sprintf($path,$code); + + // flags not in the package ! + if(!file_exists($normalPath)) + { + return sprintf($path, 'xx'); + } + return $normalPath; +} + +function Piwik_ContinentTranslate($label) +{ + if($label == 'unk') + { + return Piwik_Translate('General_Unknown'); + } + + return Piwik_Translate('UserCountry_continent_'. $label); +} + +function Piwik_CountryTranslate($label) +{ + if($label == 'xx') + { + return Piwik_Translate('General_Unknown'); + } + return Piwik_Translate('UserCountry_country_'. $label); +}
\ No newline at end of file diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php index e196c48226..6b0895145f 100644 --- a/plugins/UserSettings/UserSettings.php +++ b/plugins/UserSettings/UserSettings.php @@ -9,8 +9,6 @@ * @package Piwik_UserSettings */ -require_once "UserSettings/functions.php"; - /** * @package Piwik_UserSettings */ @@ -73,6 +71,8 @@ class Piwik_UserSettings extends Piwik_Plugin function archiveDay( $notification ) { + require_once "UserSettings/functions.php"; + $archiveProcessing = $notification->getNotificationObject(); $this->archiveProcessing = $archiveProcessing; |