Permalink
Browse files

Refs #2992 Site Search KABOOM, Refs #49

Implementing Site Search tracking & reporting in Piwik core!

 * New Admin UI to customize, for each site, wheter site search is enabled. Also options to set default values to use.
 * New Reports: Searches, Searches with no result, Search categories, Top Pages Following a Search
 * to track "No result keyword" users will have to tag their site with a JS call, or add a new parameter to the search result page &search_count=X (X being zero for no result searches)
 * Reports works with Row evolution, PDF/HTML reports, Piwik Mobile
 * idaction_url is now NULLable because, Site Search records a page with idaction_name == Keyword, and idaction_url == NULL. This ensures that the Site Searches don't create "Page URL Not defined" records. 
 * updates to Tracker JS API, new function trackSiteSearch, also added in PHP tracker
 * New fields in log_visit to track searches
 * new segment, "searches" which can be used to select visitors who did a search ie. searches>0 or those who searched a lot, ie searches>10
 
 TODO: 
  * commmit integration test, TESTING, DOCS, FAQ, release, and a nice Prayer to the universe and the stars, hoping that I can code a major new feature without any bug...
  * It would be awesome to have compatiblity with Transitions so we can see, for a given site search, what are the starting pages and Destination pages
  
 Thank you for your patience Timo, 
 and thank in advance everyone for your help Testing this new feature!
 


git-svn-id: http://dev.piwik.org/svn/trunk@7190 59fd770c-687e-43c8-a1e3-f5a4ff64c105
  • Loading branch information...
1 parent 5bc36eb commit 5364959053ad9f086a37eff591bed7db7de67add @mattab mattab committed Oct 15, 2012
Showing with 6,626 additions and 619 deletions.
  1. +5 −0 config/global.ini.php
  2. +6 −1 core/Archive.php
  3. +21 −2 core/Common.php
  4. +2 −2 core/DataTable/Filter/AddSummaryRow.php
  5. +22 −7 core/DataTable/Filter/ColumnDelete.php
  6. +5 −1 core/Db/Schema/Myisam.php
  7. +10 −2 core/Piwik.php
  8. +1 −0 core/PluginsFunctions/WidgetsList.php
  9. +1 −1 core/ScheduledTask.php
  10. +33 −2 core/Site.php
  11. +0 −20 core/Tracker.php
  12. +350 −70 core/Tracker/Action.php
  13. +2 −2 core/Tracker/GoalManager.php
  14. +18 −16 core/Tracker/Visit.php
  15. +2 −3 core/Translate.php
  16. +52 −0 core/Updates/1.9-b16.php
  17. +1 −1 core/Version.php
  18. +0 −5 core/Visualization/Chart.php
  19. +0 −8 core/testMinimumPhpVersion.php
  20. +25 −1 js/piwik.js
  21. +0 −4 lang/am.php
  22. +0 −3 lang/be.php
  23. +1 −4 lang/de.php
  24. +44 −1 lang/en.php
  25. +0 −3 lang/fi.php
  26. +0 −3 lang/sv.php
  27. +34 −2 libs/PiwikTracker/PiwikTracker.php
  28. +14 −13 piwik.js
  29. +15 −6 plugins/API/API.php
  30. +114 −3 plugins/Actions/API.php
  31. +171 −16 plugins/Actions/Actions.php
  32. +87 −15 plugins/Actions/Archiving.php
  33. +22 −4 plugins/Actions/ArchivingHelper.php
  34. +115 −41 plugins/Actions/Controller.php
  35. +19 −0 plugins/Actions/templates/indexSiteSearch.tpl
  36. +1 −1 plugins/CustomVariables/API.php
  37. +9 −7 plugins/Goals/API.php
  38. +20 −2 plugins/Live/API.php
  39. +2 −0 plugins/Live/templates/lastVisits.tpl
  40. +17 −19 plugins/Live/templates/visitorLog.tpl
  41. +107 −9 plugins/SitesManager/API.php
  42. +8 −0 plugins/SitesManager/Controller.php
  43. +27 −8 plugins/SitesManager/SitesManager.php
  44. +112 −12 plugins/SitesManager/templates/SitesManager.js
  45. +55 −12 plugins/SitesManager/templates/SitesManager.tpl
  46. +6 −5 plugins/UserCountry/UserCountry.php
  47. +25 −4 plugins/VisitsSummary/Controller.php
  48. +7 −0 plugins/VisitsSummary/templates/sparklines.tpl
  49. +1 −0 tests/PHPUnit/Core/ArchiveProcessingTest.php
  50. +42 −7 tests/PHPUnit/Core/Tracker/ActionTest.php
  51. +2 −1 tests/PHPUnit/Core/Tracker/VisitTest.php
  52. +1 −1 tests/PHPUnit/Integration/NoVisitTest.php
  53. +1 −1 tests/PHPUnit/Integration/OneVisitorOneWebsite_SeveralDaysDateRange_ArchivingTestsTest.php
  54. +3 −2 tests/PHPUnit/Integration/OneVisitorTwoVisitsTest.php
  55. +10 −4 tests/PHPUnit/Integration/OneVisitorTwoVisits_withCookieSupportTest.php
  56. +2 −1 tests/PHPUnit/Integration/RowEvolutionTest.php
  57. +13 −13 tests/PHPUnit/Integration/TwoVisitors_TwoWebsites_DifferentDays_ConversionsTest.php
  58. +5 −2 tests/PHPUnit/IntegrationTestCase.php
  59. +1 −1 tests/PHPUnit/Plugins/ActionsTest.php
  60. +45 −24 tests/PHPUnit/Plugins/SitesManagerTest.php
  61. +1 −1 tests/PHPUnit/proxy/piwik.php
  62. +1 −1 tests/index.php
  63. +2 −0 tests/integration/expected/test_ImportLogs__Actions.getPageTitlesFollowingSiteSearch_month.xml
  64. +2 −0 tests/integration/expected/test_ImportLogs__Actions.getPageUrlsFollowingSiteSearch_month.xml
  65. +2 −0 tests/integration/expected/test_ImportLogs__Actions.getSiteSearchCategories_month.xml
  66. +2 −0 tests/integration/expected/test_ImportLogs__Actions.getSiteSearchKeywords_month.xml
  67. +2 −0 tests/integration/expected/test_ImportLogs__Actions.getSiteSearchNoResultKeywords_month.xml
  68. +3 −0 tests/integration/expected/test_ImportLogs__Actions.get_month.xml
  69. +2 −0 ...s/integration/expected/test_OneVisitorTwoVisits__Actions.getPageTitlesFollowingSiteSearch_day.xml
  70. +2 −2 tests/integration/expected/test_OneVisitorTwoVisits__Actions.getPageTitles_day.xml
  71. +2 −0 tests/integration/expected/test_OneVisitorTwoVisits__Actions.getPageUrlsFollowingSiteSearch_day.xml
  72. +2 −0 tests/integration/expected/test_OneVisitorTwoVisits__Actions.getSiteSearchCategories_day.xml
  73. +2 −0 tests/integration/expected/test_OneVisitorTwoVisits__Actions.getSiteSearchKeywords_day.xml
  74. +2 −0 tests/integration/expected/test_OneVisitorTwoVisits__Actions.getSiteSearchNoResultKeywords_day.xml
  75. +3 −0 tests/integration/expected/test_OneVisitorTwoVisits__Actions.get_day.xml
  76. +1 −1 tests/integration/expected/test_OneVisitorTwoVisits_hideColumns___Actions.getPageTitles_day.xml
  77. +1 −1 ...tegration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getEntryPageTitles_day.xml
  78. +1 −1 ...integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getEntryPageUrls_day.xml
  79. +2 −1 ...ntegration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getExitPageTitles_day.xml
  80. +1 −0 .../integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getExitPageUrls_day.xml
  81. +1 −1 tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getOutlink_day.xml
  82. +2 −2 tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getOutlinks_day.xml
  83. +16 −0 ...cted/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageTitlesFollowingSiteSearch_day.xml
  84. +5 −4 tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageTitles_day.xml
  85. +1 −0 tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageUrl_day.xml
  86. +17 −0 ...pected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageUrlsFollowingSiteSearch_day.xml
  87. +2 −1 tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageUrls_day.xml
  88. +2 −0 ...tion/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getSiteSearchCategories_day.xml
  89. +14 −0 ...ration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getSiteSearchKeywords_day.xml
  90. +2 −0 ...xpected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getSiteSearchNoResultKeywords_day.xml
  91. +3 −0 tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.get_day.xml
  92. +20 −9 ...ntegration/expected/test_OneVisitorTwoVisits_withCookieSupport__Live.getLastVisitsDetails_day.xml
  93. +2 −2 tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Provider.getProvider_day.xml
  94. +2 −2 .../integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Referers.getRefererType_day.xml
  95. +4 −4 tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Referers.getWebsites_day.xml
  96. +2 −2 tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserCountry.getCity_day.xml
  97. +2 −2 ...integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserCountry.getContinent_day.xml
  98. +2 −2 ...s/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserCountry.getCountry_day.xml
  99. +2 −2 tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserCountry.getRegion_day.xml
  100. +2 −2 ...egration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getBrowserType_day.xml
  101. +2 −2 ...ation/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getBrowserVersion_day.xml
  102. +2 −2 .../integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getBrowser_day.xml
  103. +2 −2 ...ration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getConfiguration_day.xml
  104. +2 −2 ...tion/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getMobileVsDesktop_day.xml
  105. +2 −2 ...integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getOSFamily_day.xml
  106. +2 −2 tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getOS_day.xml
  107. +2 −2 ...tegration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getResolution_day.xml
  108. +2 −2 ...tegration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getWideScreen_day.xml
  109. +1 −1 ...integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getByDayOfWeek_day.xml
  110. +2 −2 ...ted/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getVisitInformationPerLocalTime_day.xml
  111. +2 −2 ...ed/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getVisitInformationPerServerTime_day.xml
  112. +2 −2 ...cted/test_OneVisitorTwoVisits_withCookieSupport__VisitorInterest.getNumberOfVisitsPerPage_day.xml
  113. +1 −1 ...integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.getActions_day.xml
  114. +1 −1 ...egration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.getMaxActions_day.xml
  115. +3 −3 tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.get_day.xml
  116. +0 −2 tests/integration/expected/test_OneVisitor_LongUrlsTruncated__Actions.getPageUrls_day.xml
  117. +1 −1 ...s_twoWebsites_differentDays_Actions.getPageTitles_firstSite_lastN__API.getProcessedReport_day.xml
  118. +4 −3 ...fferentDays_Conversions_Goals.getDaysToConversion_firstSite_lastN__API.getProcessedReport_day.xml
  119. +22 −9 ...sites_differentDays_Conversions_MultiSites.getAll_firstSite_lastN__API.getProcessedReport_day.xml
  120. +3 −1 ...xpected/test_TwoVisitors_twoWebsites_differentDays_Conversions_NotLastNPeriods__Goals.get_day.xml
  121. +3 −1 ...ected/test_TwoVisitors_twoWebsites_differentDays_Conversions_NotLastNPeriods__Goals.get_month.xml
  122. +7 −5 ...test_TwoVisitors_twoWebsites_differentDays_Conversions_NotLastNPeriods__VisitsSummary.get_day.xml
  123. +12 −10 ...st_TwoVisitors_twoWebsites_differentDays_Conversions_NotLastNPeriods__VisitsSummary.get_month.xml
  124. +20 −2 ...xpected/test_TwoVisitors_twoWebsites_differentDays_Conversions__Goals.getDaysToConversion_day.xml
  125. +20 −2 ...ected/test_TwoVisitors_twoWebsites_differentDays_Conversions__Goals.getDaysToConversion_month.xml
  126. +20 −2 ...pected/test_TwoVisitors_twoWebsites_differentDays_Conversions__Goals.getDaysToConversion_week.xml
  127. +20 −2 ...pected/test_TwoVisitors_twoWebsites_differentDays_Conversions__Goals.getDaysToConversion_year.xml
  128. +15 −8 ...ration/expected/test_TwoVisitors_twoWebsites_differentDays_Conversions__MultiSites.getAll_day.xml
  129. +7 −3 ...tion/expected/test_TwoVisitors_twoWebsites_differentDays_Conversions__MultiSites.getAll_month.xml
  130. +13 −7 ...ation/expected/test_TwoVisitors_twoWebsites_differentDays_Conversions__MultiSites.getAll_week.xml
  131. +7 −3 ...ation/expected/test_TwoVisitors_twoWebsites_differentDays_Conversions__MultiSites.getAll_year.xml
  132. +4 −2 ...twoWebsites_differentDays_Conversions_getMetricsFromDifferentReports__VisitsSummary.get_range.xml
  133. +2 −2 ...t_TwoVisitors_twoWebsites_differentDays_Conversions_idSiteOne___Goals.getDaysToConversion_day.xml
  134. +2 −2 ...TwoVisitors_twoWebsites_differentDays_Conversions_idSiteOne___Goals.getDaysToConversion_month.xml
  135. +2 −2 ..._TwoVisitors_twoWebsites_differentDays_Conversions_idSiteOne___Goals.getDaysToConversion_week.xml
  136. +2 −2 ..._TwoVisitors_twoWebsites_differentDays_Conversions_idSiteOne___Goals.getDaysToConversion_year.xml
  137. +15 −8 ...cted/test_TwoVisitors_twoWebsites_differentDays_Conversions_idSiteOne___MultiSites.getAll_day.xml
  138. +7 −3 ...ed/test_TwoVisitors_twoWebsites_differentDays_Conversions_idSiteOne___MultiSites.getAll_month.xml
  139. +13 −7 ...ted/test_TwoVisitors_twoWebsites_differentDays_Conversions_idSiteOne___MultiSites.getAll_week.xml
  140. +7 −3 ...ted/test_TwoVisitors_twoWebsites_differentDays_Conversions_idSiteOne___MultiSites.getAll_year.xml
  141. +9 −7 tests/integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageTitles_day.xml
  142. +9 −7 .../integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageTitles_month.xml
  143. +9 −7 ...s/integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageTitles_week.xml
  144. +9 −7 ...s/integration/expected/test_TwoVisitors_twoWebsites_differentDays__Actions.getPageTitles_year.xml
  145. +6 −6 ...ion/expected/test_TwoVisitors_twoWebsites_differentDays_idSiteOne___Actions.getPageTitles_day.xml
  146. +6 −6 ...n/expected/test_TwoVisitors_twoWebsites_differentDays_idSiteOne___Actions.getPageTitles_month.xml
  147. +6 −6 ...on/expected/test_TwoVisitors_twoWebsites_differentDays_idSiteOne___Actions.getPageTitles_week.xml
  148. +6 −6 ...on/expected/test_TwoVisitors_twoWebsites_differentDays_idSiteOne___Actions.getPageTitles_year.xml
  149. +4,335 −0 ...twoWebsites_differentDays_scheduled_report_in_html__PDFReports.generateReport_month.original.html
  150. +1 −1 ...differentDays_scheduled_report_in_html_tables_only__PDFReports.generateReport_month.original.html
  151. BIN ...s_twoWebsites_differentDays_scheduled_report_in_pdf__PDFReports.generateReport_month.original.pdf
  152. BIN ...s_differentDays_scheduled_report_in_pdf_tables_only__PDFReports.generateReport_month.original.pdf
  153. +7 −0 tests/integration/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml
  154. +10 −0 .../integration/expected/test_noVisit_PeriodIsLast__Actions.getPageTitlesFollowingSiteSearch_day.xml
  155. +10 −0 ...integration/expected/test_noVisit_PeriodIsLast__Actions.getPageTitlesFollowingSiteSearch_week.xml
  156. +10 −0 tests/integration/expected/test_noVisit_PeriodIsLast__Actions.getPageUrlsFollowingSiteSearch_day.xml
  157. +10 −0 ...s/integration/expected/test_noVisit_PeriodIsLast__Actions.getPageUrlsFollowingSiteSearch_week.xml
  158. +3 −0 tests/integration/expected/test_noVisit_PeriodIsLast__Actions.getSiteSearchCategories_day.xml
  159. +3 −0 tests/integration/expected/test_noVisit_PeriodIsLast__Actions.getSiteSearchCategories_week.xml
  160. +10 −0 tests/integration/expected/test_noVisit_PeriodIsLast__Actions.getSiteSearchKeywords_day.xml
  161. +10 −0 tests/integration/expected/test_noVisit_PeriodIsLast__Actions.getSiteSearchKeywords_week.xml
  162. +10 −0 tests/integration/expected/test_noVisit_PeriodIsLast__Actions.getSiteSearchNoResultKeywords_day.xml
  163. +10 −0 tests/integration/expected/test_noVisit_PeriodIsLast__Actions.getSiteSearchNoResultKeywords_week.xml
  164. +2 −0 tests/integration/expected/test_noVisit__Actions.getPageTitlesFollowingSiteSearch_day.xml
  165. +2 −0 tests/integration/expected/test_noVisit__Actions.getPageUrlsFollowingSiteSearch_day.xml
  166. +2 −0 tests/integration/expected/test_noVisit__Actions.getSiteSearchCategories_day.xml
  167. +2 −0 tests/integration/expected/test_noVisit__Actions.getSiteSearchKeywords_day.xml
  168. +2 −0 tests/integration/expected/test_noVisit__Actions.getSiteSearchNoResultKeywords_day.xml
  169. +3 −0 tests/integration/expected/test_noVisit__Actions.get_day.xml
  170. +15 −5 tests/javascript/index.php
View
@@ -369,6 +369,11 @@
; maximum length of a Page Title or a Page URL recorded in the log_action.name table
page_maximum_length = 1024;
+; By default, when a request is identified as a "Internal Site Search", the URL will not be recorded. This is for performance reasons
+; (the less unique URLs in Piwik the better). Piwik will track, for each Site Search: "Search Keyword",
+; and optionally the "Search Category" and "Search result count". You can set this to 1 to enable tracking Site Search URLs.
+action_sitesearch_record_url = 0
+
; Anonymize a visitor's IP address after testing for "Ip exclude"
; This value is the number of octets in IP address to mask; if the AnonymizeIP plugin is deactivated, this value is ignored.
; For IPv4 addresses, valid values are 0..4; for IPv6 addresses, valid values are 0..16
View
@@ -75,6 +75,10 @@
const INDEX_ECOMMERCE_ORDERS = 26;
const INDEX_ECOMMERCE_ITEM_PRICE_VIEWED = 27;
+ // Site Search
+ const INDEX_SITE_SEARCH_HAS_NO_RESULT = 28;
+ const INDEX_PAGE_IS_FOLLOWING_SITE_SEARCH_NB_HITS = 29;
+
// Goal reports
const INDEX_GOAL_NB_CONVERSIONS = 1;
const INDEX_GOAL_REVENUE = 2;
@@ -113,7 +117,8 @@
Piwik_Archive::INDEX_PAGE_ENTRY_NB_ACTIONS => 'entry_nb_actions',
Piwik_Archive::INDEX_PAGE_ENTRY_SUM_VISIT_LENGTH => 'entry_sum_visit_length',
Piwik_Archive::INDEX_PAGE_ENTRY_BOUNCE_COUNT => 'entry_bounce_count',
-
+ Piwik_Archive::INDEX_PAGE_IS_FOLLOWING_SITE_SEARCH_NB_HITS => 'nb_hits_following_search',
+
// Items reports metrics
Piwik_Archive::INDEX_ECOMMERCE_ITEM_REVENUE => 'revenue',
Piwik_Archive::INDEX_ECOMMERCE_ITEM_QUANTITY => 'quantity',
View
@@ -416,7 +416,6 @@ static public function getArrayFromQueryString( $urlQuery )
{
$urlQuery = substr($urlQuery, 1);
}
-
$separator = '&';
$urlQuery = $separator . $urlQuery;
@@ -891,7 +890,7 @@ static public function getRequestVar($varName, $varDefault = null, $varType = nu
{
if( is_null($varDefault))
{
- throw new Exception("The parameter '$varName' isn't set in the Request, and a default value wasn't provided.");
+ throw new Exception("The parameter '$varName' isn't set in the Request, and a default value wasn't provided." );
}
else
{
@@ -1942,3 +1941,23 @@ function destroy(&$var)
unset($var);
$var = null;
}
+
+if(!function_exists('printDebug'))
+{
+ function printDebug( $info = '' )
+ {
+ if(isset($GLOBALS['PIWIK_TRACKER_DEBUG']) && $GLOBALS['PIWIK_TRACKER_DEBUG'])
+ {
+ if(is_array($info))
+ {
+ print("<pre>");
+ print(htmlspecialchars(var_export($info,true), ENT_QUOTES));
+ print("</pre>");
+ }
+ else
+ {
+ print(htmlspecialchars($info, ENT_QUOTES) . "<br />\n");
+ }
+ }
+ }
+}
@@ -77,12 +77,12 @@ public function filter($table)
//FIXME: I'm not sure why it could return false, but it was reported in: http://forum.piwik.org/read.php?2,89324,page=1#msg-89442
if($summaryRow)
{
- $newRow->sumRow($summaryRow);
+ $newRow->sumRow($summaryRow, $enableCopyMetadata = false);
}
}
else
{
- $newRow->sumRow($rows[$i]);
+ $newRow->sumRow($rows[$i], $enableCopyMetadata = false);
}
}
@@ -33,6 +33,13 @@ class Piwik_DataTable_Filter_ColumnDelete extends Piwik_DataTable_Filter
* @var array
*/
private $columnsToKeep;
+
+ /**
+ * Delete the column, only if the value was zero
+ *
+ * @var bool
+ */
+ private $deleteIfZeroOnly;
/**
* Constructor.
@@ -44,7 +51,7 @@ class Piwik_DataTable_Filter_ColumnDelete extends Piwik_DataTable_Filter
* comma-separated list of column names. Columns not in
* this list will be removed.
*/
- public function __construct( $table, $columnsToRemove, $columnsToKeep = array() )
+ public function __construct( $table, $columnsToRemove, $columnsToKeep = array(), $deleteIfZeroOnly = false )
{
parent::__construct($table);
@@ -60,28 +67,36 @@ public function __construct( $table, $columnsToRemove, $columnsToKeep = array()
$this->columnsToRemove = $columnsToRemove;
$this->columnsToKeep = array_flip($columnsToKeep); // flip so we can use isset instead of in_array
-
- // always do recursive filter
- $this->enableRecursive(true);
+ $this->deleteIfZeroOnly = $deleteIfZeroOnly;
}
-
+
/**
* Filters the given DataTable. Removes columns that are not desired from
* each DataTable row.
- *
+ *
* @param Piwik_DataTable $table
*/
public function filter($table)
{
+ // always do recursive filter
+ $this->enableRecursive(true);
$recurse = false; // only recurse if there are columns to remove/keep
-
+
// remove columns specified in $this->columnsToRemove
if (!empty($this->columnsToRemove))
{
foreach ($table->getRows() as $row)
{
foreach ($this->columnsToRemove as $column)
{
+ if($this->deleteIfZeroOnly)
+ {
+ $value = $row->getColumn($column);
+ if($value === false || !empty($value))
+ {
+ continue;
+ }
+ }
$row->deleteColumn($column);
}
}
@@ -82,6 +82,9 @@ public function getTablesCreateSql()
main_url VARCHAR(255) NOT NULL,
ts_created TIMESTAMP NULL,
ecommerce TINYINT DEFAULT 0,
+ sitesearch TINYINT DEFAULT 1,
+ sitesearch_keyword_parameters TEXT NOT NULL,
+ sitesearch_category_parameters TEXT NOT NULL,
timezone VARCHAR( 50 ) NOT NULL,
currency CHAR( 3 ) NOT NULL,
excluded_ips TEXT NOT NULL,
@@ -187,6 +190,7 @@ class_name VARCHAR(255) NULL,
visit_entry_idaction_url INTEGER(11) UNSIGNED NOT NULL,
visit_entry_idaction_name INTEGER(11) UNSIGNED NOT NULL,
visit_total_actions SMALLINT(5) UNSIGNED NOT NULL,
+ visit_total_searches SMALLINT(5) UNSIGNED NOT NULL,
visit_total_time SMALLINT(5) UNSIGNED NOT NULL,
visit_goal_converted TINYINT(1) NOT NULL,
visit_goal_buyer TINYINT(1) NOT NULL,
@@ -310,7 +314,7 @@ class_name VARCHAR(255) NULL,
idvisitor BINARY(8) NOT NULL,
server_time DATETIME NOT NULL,
idvisit INTEGER(10) UNSIGNED NOT NULL,
- idaction_url INTEGER(10) UNSIGNED NOT NULL,
+ idaction_url INTEGER(10) UNSIGNED DEFAULT NULL,
idaction_url_ref INTEGER(10) UNSIGNED NOT NULL,
idaction_name INTEGER(10) UNSIGNED,
idaction_name_ref INTEGER(10) UNSIGNED NOT NULL,
View
@@ -2453,6 +2453,7 @@ static public function createTableFromCSVFile($tableName, $fields, $filePath, $f
return true;
} catch(Exception $e) {
+// echo $sql . ' ---- ' . $e->getMessage();
if(!Zend_Registry::get('db')->isErrNo($e, '1148'))
{
Piwik::log("LOAD DATA INFILE failed... Error was:" . $e->getMessage());
@@ -2498,16 +2499,23 @@ static public function tableInsertBatch($tableName, $fields, $values)
self::createCSVFile($filePath, $fileSpec, $values);
+ if(!file_exists($filePath))
+ {
+ throw new Exception("File $filePath could not be created.");
+ }
$rc = self::createTableFromCSVFile($tableName, $fields, $filePath, $fileSpec);
if($rc)
{
unlink($filePath);
return true;
}
-
- throw new Exception('unknown cause');
+ else
+ {
+ throw new Exception('unknown cause');
+ }
} catch(Exception $e) {
+// echo "LOAD DATA INFILE failed or not supported, falling back to normal INSERTs... Error was:" . $e->getMessage();
Piwik::log("LOAD DATA INFILE failed or not supported, falling back to normal INSERTs... Error was:" . $e->getMessage());
}
}
@@ -70,6 +70,7 @@ protected static function _sortWidgetCategories($a, $b)
'General_Visitors',
'UserSettings_VisitorSettings',
'Actions_Actions',
+ 'Actions_SubmenuSitesearch',
'Referers_Referers',
'Goals_Goals',
'Goals_Ecommerce',
View
@@ -23,7 +23,7 @@ class Piwik_ScheduledTask
const NORMAL_PRIORITY = 6;
const HIGH_PRIORITY = 3;
const HIGHEST_PRIORITY = 0;
-
+
/**
* Class name where the specified method is located
* @var string
View
@@ -184,6 +184,26 @@ function isEcommerceEnabled()
return $this->get('ecommerce') == 1;
}
+ function getSearchKeywordParameters()
+ {
+ return $this->get('sitesearch_keyword_parameters');
+ }
+
+ function getSearchCategoryParameters()
+ {
+ return $this->get('sitesearch_category_parameters');
+ }
+
+ /**
+ * Returns whether Site Search Tracking is enabled for the site
+ *
+ * @return bool
+ */
+ function isSiteSearchEnabled()
+ {
+ return $this->get('sitesearch') == 1;
+ }
+
/**
* Checks the given string for valid site ids and returns them as an array
*
@@ -283,10 +303,10 @@ static public function getMainUrlFor($idsite)
{
return self::getFor($idsite, 'main_url');
}
-
+
/**
* Returns whether the site with the specified ID is ecommerce enabled
- *
+ *
* @param int $idsite The site ID.
* @return string
*/
@@ -295,6 +315,17 @@ static public function isEcommerceEnabledFor($idsite)
return self::getFor($idsite, 'ecommerce') == 1;
}
+ /**
+ * Returns whether the site with the specified ID is Site Search enabled
+ *
+ * @param int $idsite The site ID.
+ * @return string
+ */
+ static public function isSiteSearchEnabledFor($idsite)
+ {
+ return self::getFor($idsite, 'sitesearch') == 1;
+ }
+
/**
* Returns the currency of the site with the specified ID.
*
View
@@ -707,26 +707,6 @@ public static function setTestEnvironment( $args = null, $requestMethod = null )
}
}
-if(!function_exists('printDebug'))
-{
- function printDebug( $info = '' )
- {
- if(isset($GLOBALS['PIWIK_TRACKER_DEBUG']) && $GLOBALS['PIWIK_TRACKER_DEBUG'])
- {
- if(is_array($info))
- {
- print("<pre>");
- print(htmlspecialchars(var_export($info,true), ENT_QUOTES));
- print("</pre>");
- }
- else
- {
- print(htmlspecialchars($info, ENT_QUOTES) . "<br />\n");
- }
- }
- }
-}
-
if(!function_exists('Piwik_Translate'))
{
function Piwik_Translate($string, $args = array())
Oops, something went wrong.

0 comments on commit 5364959

Please sign in to comment.