Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VisitorLog.php 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * Piwik - free/libre analytics platform
  4. *
  5. * @link http://piwik.org
  6. * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
  7. *
  8. */
  9. namespace Piwik\Plugins\Live;
  10. use Piwik\Common;
  11. use Piwik\Piwik;
  12. use Piwik\Plugin\Visualization;
  13. use Piwik\View;
  14. /**
  15. * A special DataTable visualization for the Live.getLastVisitsDetails API method.
  16. *
  17. * @property VisitorLog\Config $config
  18. */
  19. class VisitorLog extends Visualization
  20. {
  21. const ID = 'Piwik\Plugins\Live\VisitorLog';
  22. const TEMPLATE_FILE = "@Live/_dataTableViz_visitorLog.twig";
  23. public static function getDefaultConfig()
  24. {
  25. return new VisitorLog\Config();
  26. }
  27. public function beforeLoadDataTable()
  28. {
  29. $this->requestConfig->addPropertiesThatShouldBeAvailableClientSide(array(
  30. 'filter_limit',
  31. 'filter_offset',
  32. 'filter_sort_column',
  33. 'filter_sort_order',
  34. ));
  35. if (!is_numeric($this->requestConfig->filter_limit)) {
  36. $this->requestConfig->filter_limit = 20;
  37. }
  38. $this->requestConfig->filter_sort_column = 'lastActionTimestamp';
  39. $this->requestConfig->disable_generic_filters = true;
  40. $offset = Common::getRequestVar('filter_offset', 0);
  41. $limit = Common::getRequestVar('filter_limit', $this->requestConfig->filter_limit);
  42. $this->config->filters[] = array('Limit', array($offset, $limit));
  43. }
  44. /**
  45. * Configure visualization.
  46. */
  47. public function beforeRender()
  48. {
  49. $this->config->disable_row_actions = true;
  50. $this->config->datatable_js_type = 'VisitorLog';
  51. $this->config->enable_sort = false;
  52. $this->config->show_search = false;
  53. $this->config->show_exclude_low_population = false;
  54. $this->config->show_offset_information = false;
  55. $this->config->show_all_views_icons = false;
  56. $this->config->show_table_all_columns = false;
  57. $this->config->show_export_as_rss_feed = false;
  58. $this->config->documentation = Piwik::translate('Live_VisitorLogDocumentation', array('<br />', '<br />'));
  59. $filterEcommerce = Common::getRequestVar('filterEcommerce', 0, 'int');
  60. if (!is_array($this->config->custom_parameters)) {
  61. $this->config->custom_parameters = array();
  62. }
  63. // set a very high row count so that the next link in the footer of the data table is always shown
  64. $this->config->custom_parameters['totalRows'] = 10000000;
  65. $this->config->custom_parameters['smallWidth'] = (1 == Common::getRequestVar('small', 0, 'int'));
  66. $this->config->custom_parameters['filterEcommerce'] = $filterEcommerce;
  67. $this->config->custom_parameters['pageUrlNotDefined'] = Piwik::translate('General_NotDefined', Piwik::translate('Actions_ColumnPageURL'));
  68. $this->config->footer_icons = array(
  69. array(
  70. 'class' => 'tableAllColumnsSwitch',
  71. 'buttons' => array(
  72. array(
  73. 'id' => static::ID,
  74. 'title' => Piwik::translate('Live_LinkVisitorLog'),
  75. 'icon' => 'plugins/Morpheus/images/table.png'
  76. )
  77. )
  78. )
  79. );
  80. // determine if each row has ecommerce activity or not
  81. if ($filterEcommerce) {
  82. $this->dataTable->filter(
  83. 'ColumnCallbackAddMetadata',
  84. array(
  85. 'actionDetails',
  86. 'hasEcommerce',
  87. function ($actionDetails) use ($filterEcommerce) {
  88. foreach ($actionDetails as $action) {
  89. $isEcommerceOrder = $action['type'] == 'ecommerceOrder'
  90. && $filterEcommerce == \Piwik\Plugins\Goals\Controller::ECOMMERCE_LOG_SHOW_ORDERS;
  91. $isAbandonedCart = $action['type'] == 'ecommerceAbandonedCart'
  92. && $filterEcommerce == \Piwik\Plugins\Goals\Controller::ECOMMERCE_LOG_SHOW_ABANDONED_CARTS;
  93. if($isAbandonedCart || $isEcommerceOrder) {
  94. return true;
  95. }
  96. }
  97. return false;
  98. }
  99. )
  100. );
  101. }
  102. }
  103. }