diff --git a/config/global.ini.php b/config/global.ini.php index 060167b9200bd165d689c8553c3e714d6e469795..aad0fd33819af603d2863019042865ee83858ceb 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -249,8 +249,9 @@ default_language = en datatable_default_limit = 10 ; Each datatable report has a Row Limit selector at the bottom right. -; By default you can select from 5 to 500 rows. You may customise the values below: -datatable_row_limits = "5,10,25,50,100,250,500" +; By default you can select from 5 to 500 rows. You may customise the values below +; -1 will be displayed as 'all' and it will export all rows (filter_limit=-1) +datatable_row_limits = "5,10,25,50,100,250,500,-1" ; default number of rows returned in API responses ; this value is overwritten by the '# Rows to display' selector. diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php index 7f194f7d1a52bbdc0f0a98ac0a245bfff0ea3c3a..e714ecded7b02a6ea8bd5247a003d488ad2b214e 100644 --- a/core/Tracker/Request.php +++ b/core/Tracker/Request.php @@ -288,6 +288,15 @@ class Request 'i' => (string)Common::getRequestVar('m', $this->getCurrentDate("i"), 'int', $this->params), 's' => (string)Common::getRequestVar('s', $this->getCurrentDate("s"), 'int', $this->params) ); + if($localTimes['h'] < 0 || $localTimes['h'] > 23) { + $localTimes['h'] = 0; + } + if($localTimes['i'] < 0 || $localTimes['i'] > 59) { + $localTimes['i'] = 0; + } + if($localTimes['s'] < 0 || $localTimes['s'] > 59) { + $localTimes['s'] = 0; + } foreach ($localTimes as $k => $time) { if (strlen($time) == 1) { $localTimes[$k] = '0' . $time; diff --git a/plugins/CoreHome/CoreHome.php b/plugins/CoreHome/CoreHome.php index 7cf82cfd3bcd5da8e21085ecffae20e2a6390066..ba0f3edd822b39f2e1253ffab590666d33de457a 100644 --- a/plugins/CoreHome/CoreHome.php +++ b/plugins/CoreHome/CoreHome.php @@ -252,6 +252,7 @@ class CoreHome extends \Piwik\Plugin $translationKeys[] = 'Intl_Day_Min_StandAlone_6'; $translationKeys[] = 'Intl_Day_Min_StandAlone_7'; $translationKeys[] = 'General_And'; + $translationKeys[] = 'General_All'; $translationKeys[] = 'General_Search'; $translationKeys[] = 'General_Clear'; $translationKeys[] = 'General_MoreDetails'; diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js index 0232d91ec623a01e8c1644b26cec070efb5ccd69..56837809fc0da0dee7f9ef6b2ecb9e0cc66d8795 100644 --- a/plugins/CoreHome/javascripts/dataTable.js +++ b/plugins/CoreHome/javascripts/dataTable.js @@ -506,13 +506,20 @@ $.extend(DataTable.prototype, UIControl.prototype, { }; } + function getFilterLimitAsString(limit) { + if (limit == '-1') { + return _pk_translate('General_All').toLowerCase(); + } + return limit; + } + // setup limit control - $('.limitSelection', domElem).append('<div><span>' + self.param[limitParamName] + '</span></div><ul></ul>'); + $('.limitSelection', domElem).append('<div><span value="'+ self.param[limitParamName] +'">' + getFilterLimitAsString(self.param[limitParamName]) + '</span></div><ul></ul>'); if (self.props.show_limit_control) { $('.limitSelection ul', domElem).hide(); for (var i = 0; i < numbers.length; i++) { - $('.limitSelection ul', domElem).append('<li value="' + numbers[i] + '"><span>' + numbers[i] + '</span></li>'); + $('.limitSelection ul', domElem).append('<li value="' + numbers[i] + '"><span>' + getFilterLimitAsString(numbers[i]) + '</span></li>'); } $('.limitSelection ul li:last', domElem).addClass('last'); @@ -535,12 +542,12 @@ $.extend(DataTable.prototype, UIControl.prototype, { $('.limitSelection', domElem).is('.visible') ? hide() : show(); }); $('.limitSelection ul li', domElem).on('click', function (event) { - var limit = parseInt($(event.target).text()); + var limit = parseInt($(event.target).closest('li').attr('value')); hide(); if (limit != self.param[limitParamName]) { setLimitValue(self.param, limit); - $('.limitSelection>div>span', domElem).text(limit); + $('.limitSelection>div>span', domElem).text( getFilterLimitAsString(limit)).attr('value', limit); self.reloadAjaxDataTable(); var data = {}; @@ -1045,7 +1052,7 @@ $.extend(DataTable.prototype, UIControl.prototype, { $(this).attr('href', function () { var url = $(this).attr('href') + '&token_auth=' + piwik.token_auth; - var limit = $('.limitSelection>div>span', domElem).text(); + var limit = $('.limitSelection>div>span', domElem).attr('value'); var defaultLimit = $(this).attr('filter_limit'); if (!limit || 'undefined' === limit || defaultLimit == -1) { limit = defaultLimit; diff --git a/tests/PHPUnit/Unit/Tracker/RequestTest.php b/tests/PHPUnit/Unit/Tracker/RequestTest.php index 3db5c22a4ab9afd049970f8b074c14672647fbee..7eb38059a26b394a7357837d889b83b2fc6407e8 100644 --- a/tests/PHPUnit/Unit/Tracker/RequestTest.php +++ b/tests/PHPUnit/Unit/Tracker/RequestTest.php @@ -470,6 +470,25 @@ class RequestTest extends UnitTestCase $this->assertContains($needle, $cookie . ''); } + public function test_getLocalTime() + { + $request = $this->buildRequest(array('h' => '12', 'm' => '34', 's' => '3')); + $this->assertSame('12:34:03', $request->getLocalTime()); + + + $request = $this->buildRequest(array('h' => '23', 'm' => '59', 's' => '59')); + $this->assertSame('23:59:59', $request->getLocalTime()); + } + + public function test_getLocalTime_shouldReturnValidTime_whenTimeWasInvalid() + { + $request = $this->buildRequest(array('h' => '26', 'm' => '60', 's' => '333')); + $this->assertSame('00:00:00', $request->getLocalTime()); + + $request = $this->buildRequest(array('h' => '-26', 'm' => '-60', 's' => '-333')); + $this->assertSame('00:00:00', $request->getLocalTime()); + } + public function test_getIdSite() { $request = $this->buildRequest(array('idsite' => '14')); diff --git a/tests/UI/expected-ui-screenshots b/tests/UI/expected-ui-screenshots index 05bbce1658fd4cba64a3fe0e8ba51b1a5a169594..6888230ab178bcc2518acbf2e028727c4b690102 160000 --- a/tests/UI/expected-ui-screenshots +++ b/tests/UI/expected-ui-screenshots @@ -1 +1 @@ -Subproject commit 05bbce1658fd4cba64a3fe0e8ba51b1a5a169594 +Subproject commit 6888230ab178bcc2518acbf2e028727c4b690102