Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/API/Proxy.php2
-rw-r--r--core/Container/ContainerFactory.php12
-rw-r--r--core/Date.php27
-rw-r--r--core/Db.php2
-rw-r--r--core/FrontController.php11
-rw-r--r--core/IP.php4
-rw-r--r--core/Intl/Data/Provider/DateTimeFormatProvider.php83
-rw-r--r--core/Period.php9
-rw-r--r--core/Plugin/ControllerAdmin.php3
-rw-r--r--core/SettingsServer.php7
-rw-r--r--core/Url.php1
-rw-r--r--core/Version.php2
12 files changed, 128 insertions, 35 deletions
diff --git a/core/API/Proxy.php b/core/API/Proxy.php
index 26e2ceb4cc..1d348e1b87 100644
--- a/core/API/Proxy.php
+++ b/core/API/Proxy.php
@@ -262,7 +262,7 @@ class Proxy extends Singleton
* **Example**
*
* // append (0 hits) to the end of row labels whose row has 0 hits for any report that has the 'nb_hits' metric
- * Piwik::addAction('API.Actions.getPageUrls', function (&$returnValue, $info)) {
+ * Piwik::addAction('API.Actions.getPageUrls.end', function (&$returnValue, $info)) {
* // don't process non-DataTable reports and reports that don't have the nb_hits column
* if (!($returnValue instanceof DataTableInterface)
* || in_array('nb_hits', $returnValue->getColumns())
diff --git a/core/Container/ContainerFactory.php b/core/Container/ContainerFactory.php
index 75735036aa..9c5eed1276 100644
--- a/core/Container/ContainerFactory.php
+++ b/core/Container/ContainerFactory.php
@@ -79,12 +79,7 @@ class ContainerFactory
// Development config
if ($this->isDevelopmentModeEnabled()) {
- $builder->addDefinitions(PIWIK_USER_PATH . '/config/environment/dev.php');
- }
-
- // User config
- if (file_exists(PIWIK_USER_PATH . '/config/config.php')) {
- $builder->addDefinitions(PIWIK_USER_PATH . '/config/config.php');
+ $this->addEnvironmentConfig($builder, 'dev');
}
// Environment config
@@ -92,6 +87,11 @@ class ContainerFactory
$this->addEnvironmentConfig($builder, $environment);
}
+ // User config
+ if (file_exists(PIWIK_USER_PATH . '/config/config.php')) {
+ $builder->addDefinitions(PIWIK_USER_PATH . '/config/config.php');
+ }
+
if (!empty($this->definitions)) {
foreach ($this->definitions as $definitionArray) {
$builder->addDefinitions($definitionArray);
diff --git a/core/Date.php b/core/Date.php
index bac8ce7db2..cbbe866708 100644
--- a/core/Date.php
+++ b/core/Date.php
@@ -11,6 +11,8 @@ namespace Piwik;
use Exception;
use Piwik\Container\StaticContainer;
+use Piwik\Intl\Data\Provider\DateTimeFormatProvider;
+use Piwik\Plugins\LanguagesManager\LanguagesManager;
/**
* Utility class that wraps date/time related PHP functions. Using this class can
@@ -41,15 +43,15 @@ class Date
/** The default date time string format. */
const DATE_TIME_FORMAT = 'Y-m-d H:i:s';
- const DATETIME_FORMAT_LONG = 'Intl_Format_DateTime_Long';
- const DATETIME_FORMAT_SHORT = 'Intl_Format_DateTime_Short';
- const DATE_FORMAT_LONG = 'Intl_Format_Date_Long';
- const DATE_FORMAT_DAY_MONTH = 'Intl_Format_Date_Day_Month';
- const DATE_FORMAT_SHORT = 'Intl_Format_Date_Short';
- const DATE_FORMAT_MONTH_SHORT = 'Intl_Format_Month_Short';
- const DATE_FORMAT_MONTH_LONG = 'Intl_Format_Month_Long';
- const DATE_FORMAT_YEAR = 'Intl_Format_Year';
- const TIME_FORMAT = 'Intl_Format_Time';
+ const DATETIME_FORMAT_LONG = DateTimeFormatProvider::DATE_FORMAT_LONG;
+ const DATETIME_FORMAT_SHORT = DateTimeFormatProvider::DATETIME_FORMAT_SHORT;
+ const DATE_FORMAT_LONG = DateTimeFormatProvider::DATE_FORMAT_LONG;
+ const DATE_FORMAT_DAY_MONTH = DateTimeFormatProvider::DATE_FORMAT_DAY_MONTH;
+ const DATE_FORMAT_SHORT = DateTimeFormatProvider::DATE_FORMAT_SHORT;
+ const DATE_FORMAT_MONTH_SHORT = DateTimeFormatProvider::DATE_FORMAT_MONTH_SHORT;
+ const DATE_FORMAT_MONTH_LONG = DateTimeFormatProvider::DATE_FORMAT_MONTH_LONG;
+ const DATE_FORMAT_YEAR = DateTimeFormatProvider::DATE_FORMAT_YEAR;
+ const TIME_FORMAT = DateTimeFormatProvider::TIME_FORMAT;
/**
* Max days for months (non-leap-year). See {@link addPeriod()} implementation.
@@ -622,10 +624,9 @@ class Date
{
$template = $this->replaceLegacyPlaceholders($template);
- if (substr($template, 0, 5) == 'Intl_') {
- $translator = StaticContainer::get('Piwik\Translation\Translator');
- $template = $translator->translate($template);
- }
+ $dateTimeFormatProvider = StaticContainer::get('Piwik\Intl\Data\Provider\DateTimeFormatProvider');
+
+ $template = $dateTimeFormatProvider->getFormatPattern($template);
$tokens = self::parseFormat($template);
diff --git a/core/Db.php b/core/Db.php
index 12798d2ff5..f7eae8c8b2 100644
--- a/core/Db.php
+++ b/core/Db.php
@@ -33,7 +33,7 @@ use Piwik\Db\Adapter;
*/
class Db
{
- const SQL_MODE = 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_DATE,NO_ZERO_IN_DATE';
+ const SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO';
private static $connection = null;
diff --git a/core/FrontController.php b/core/FrontController.php
index 4b47d9024b..e276ed53e7 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -66,6 +66,11 @@ class FrontController extends Singleton
public static $enableDispatch = true;
/**
+ * @var bool
+ */
+ private $initialized = false;
+
+ /**
* Executes the requested plugin controller method.
*
* @throws Exception|\Piwik\PluginDeactivatedException in case the plugin doesn't exist, the action doesn't exist,
@@ -197,11 +202,11 @@ class FrontController extends Singleton
*/
public function init()
{
- static $initialized = false;
- if ($initialized) {
+ if ($this->initialized) {
return;
}
- $initialized = true;
+
+ $this->initialized = true;
$tmpPath = StaticContainer::get('path.tmp');
diff --git a/core/IP.php b/core/IP.php
index 6e27832e48..670c674544 100644
--- a/core/IP.php
+++ b/core/IP.php
@@ -101,7 +101,7 @@ class IP
*
* @param string $csv Comma separated list of elements.
* @param array $excludedIps Optional list of excluded IP addresses (or IP address ranges).
- * @return string Last (non-excluded) IP address in the list.
+ * @return string Last (non-excluded) IP address in the list or an empty string if all given IPs are excluded.
*/
public static function getLastIpFromList($csv, $excludedIps = null)
{
@@ -115,6 +115,8 @@ class IP
return $element;
}
}
+
+ return '';
}
return trim(Common::sanitizeInputValue($csv));
}
diff --git a/core/Intl/Data/Provider/DateTimeFormatProvider.php b/core/Intl/Data/Provider/DateTimeFormatProvider.php
new file mode 100644
index 0000000000..90ffad609f
--- /dev/null
+++ b/core/Intl/Data/Provider/DateTimeFormatProvider.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Intl\Data\Provider;
+
+/**
+ * Provides date and time formats.
+ */
+class DateTimeFormatProvider
+{
+ const DATETIME_FORMAT_LONG = 1;
+ const DATETIME_FORMAT_SHORT = 2;
+ const DATE_FORMAT_LONG = 10;
+ const DATE_FORMAT_DAY_MONTH = 11;
+ const DATE_FORMAT_SHORT = 12;
+ const DATE_FORMAT_MONTH_SHORT = 13;
+ const DATE_FORMAT_MONTH_LONG = 14;
+ const DATE_FORMAT_YEAR = 15;
+ const TIME_FORMAT = 20;
+
+ /**
+ * Returns the format pattern for the given format type
+ *
+ * @param int $format one of the format constants
+ *
+ * @return string
+ */
+ public function getFormatPattern($format)
+ {
+ switch ($format) {
+ case self::DATETIME_FORMAT_LONG:
+ return 'EEEE, MMMM d, y HH:mm:ss';
+
+ case self::DATETIME_FORMAT_SHORT:
+ return 'MMM d, y HH:mm:ss';
+
+ case self::DATE_FORMAT_LONG:
+ return 'EEEE, MMMM d, y';
+
+ case self::DATE_FORMAT_DAY_MONTH:
+ return 'E, MMM d';
+
+ case self::DATE_FORMAT_SHORT:
+ return 'MMM d, y';
+
+ case self::DATE_FORMAT_MONTH_SHORT:
+ return 'MMM y';
+
+ case self::DATE_FORMAT_MONTH_LONG:
+ return 'MMMM y';
+
+ case self::DATE_FORMAT_YEAR:
+ return 'y';
+
+ case self::TIME_FORMAT:
+ return 'HH:mm:ss';
+ }
+
+ return $format;
+ }
+
+ /**
+ * Returns interval format pattern for the given format type
+ *
+ * @param bool $short whether to return short or long format pattern
+ * @param string $maxDifference maximal difference in interval dates (Y, M or D)
+ *
+ * @return string
+ */
+ public function getRangeFormatPattern($short=false, $maxDifference='Y')
+ {
+ if ($short) {
+ return 'MMM d, y – MMM d, y';
+ }
+
+ return 'MMMM d, y – MMMM d, y';
+ }
+}
diff --git a/core/Period.php b/core/Period.php
index 70a47d2905..aecf6362bf 100644
--- a/core/Period.php
+++ b/core/Period.php
@@ -371,12 +371,9 @@ abstract class Period
$maxDifference = 'M';
}
- return $this->translator->translate(
- sprintf(
- 'Intl_Format_Interval_%s_%s',
- $short ? 'Short' : 'Long',
- $maxDifference
- ));
+ $dateTimeFormatProvider = StaticContainer::get('Piwik\Intl\Data\Provider\DateTimeFormatProvider');
+
+ return $dateTimeFormatProvider->getRangeFormatPattern($short, $maxDifference);
}
/**
diff --git a/core/Plugin/ControllerAdmin.php b/core/Plugin/ControllerAdmin.php
index 3431d70156..42f44706b1 100644
--- a/core/Plugin/ControllerAdmin.php
+++ b/core/Plugin/ControllerAdmin.php
@@ -128,8 +128,7 @@ abstract class ControllerAdmin extends Controller
if (!$notifyPhpIsEOL) {
return;
}
- $dateDropSupport = Date::factory('2015-05-01')->getLocalized('%longMonth% %longYear%');
- $message = Piwik::translate('General_WarningPiwikWillStopSupportingPHPVersion', $dateDropSupport)
+ $message = Piwik::translate('General_WarningPiwikWillStopSupportingPHPVersion')
. "\n "
. Piwik::translate('General_WarningPhpVersionXIsTooOld', '5.3');
diff --git a/core/SettingsServer.php b/core/SettingsServer.php
index 3f6fbb8878..d84e3ff483 100644
--- a/core/SettingsServer.php
+++ b/core/SettingsServer.php
@@ -127,9 +127,14 @@ class SettingsServer
{
static $gd = null;
if (is_null($gd)) {
+ $gd = false;
+
$extensions = @get_loaded_extensions();
- $gd = in_array('gd', $extensions) && function_exists('imageftbbox');
+ if (is_array($extensions)) {
+ $gd = in_array('gd', $extensions) && function_exists('imageftbbox');
+ }
}
+
return $gd;
}
diff --git a/core/Url.php b/core/Url.php
index fc618d752b..b5f885a7fc 100644
--- a/core/Url.php
+++ b/core/Url.php
@@ -216,6 +216,7 @@ class Url
return true;
}
}
+
// if host is in hardcoded whitelist, assume it's valid
if (in_array($host, self::getAlwaysTrustedHosts())) {
return true;
diff --git a/core/Version.php b/core/Version.php
index ee5bad9caa..77b3d42f1c 100644
--- a/core/Version.php
+++ b/core/Version.php
@@ -20,7 +20,7 @@ final class Version
* The current Piwik version.
* @var string
*/
- const VERSION = '2.15.0';
+ const VERSION = '2.15.1-b1';
public function isStableVersion($version)
{