Columns
6 months ago
Groups
1 year ago
Table.php
4 days ago
Table_Campaigns.php
4 days ago
Table_Clicks.php
4 days ago
Table_Devices.php
4 days ago
Table_Geo.php
4 days ago
Table_Journeys.php
4 days ago
Table_Pages.php
4 days ago
Table_Referrers.php
4 days ago
Table_Journeys.php
81 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\Tables; |
| 4 | |
| 5 | use IAWP\ColumnOptions\Options; |
| 6 | use IAWP\ColumnOptions\Plugins\Countries; |
| 7 | use IAWP\ColumnOptions\Plugins\DeviceBrowsers; |
| 8 | use IAWP\ColumnOptions\Plugins\DeviceTypes; |
| 9 | use IAWP\ColumnOptions\Plugins\FormConversions; |
| 10 | use IAWP\ColumnOptions\Plugins\LinkPatternConversions; |
| 11 | use IAWP\Rows\Filter; |
| 12 | use IAWP\Rows\Journeys; |
| 13 | use IAWP\Statistics\Journey_Statistics; |
| 14 | use IAWP\Tables\Columns\Column; |
| 15 | use IAWP\Tables\Groups\Group; |
| 16 | use IAWP\Tables\Groups\Groups; |
| 17 | /** @internal */ |
| 18 | class Table_Journeys extends \IAWP\Tables\Table |
| 19 | { |
| 20 | protected $default_sorting_column = 'created_at'; |
| 21 | public function id() : string |
| 22 | { |
| 23 | return 'journeys'; |
| 24 | } |
| 25 | public function name() : string |
| 26 | { |
| 27 | return \__('Journeys', 'independent-analytics'); |
| 28 | } |
| 29 | public function allow_downloading() : bool |
| 30 | { |
| 31 | return \false; |
| 32 | } |
| 33 | public function get_table_toolbar_markup() |
| 34 | { |
| 35 | return ''; |
| 36 | } |
| 37 | public function get_table_markup(string $sort_column, string $sort_direction) |
| 38 | { |
| 39 | return \IAWPSCOPED\iawp_render('journeys.table', ['table' => $this, 'rows' => [], 'render_skeleton' => \true, 'page_size' => \IAWPSCOPED\iawp()->pagination_page_size()]); |
| 40 | } |
| 41 | public function get_rendered_template(array $rows, bool $just_rows, string $sort_column, string $sort_direction) |
| 42 | { |
| 43 | return \IAWPSCOPED\iawp_render('journeys.rows', ['table' => $this, 'rows' => $rows]); |
| 44 | } |
| 45 | public function resolve_filter_conflicts(array $filters, string $filter_logic) : array |
| 46 | { |
| 47 | // Are you back again to make changes or are you doing this for another table? |
| 48 | // Consider moving the rules to a configuration object that'll be easier to change and reuse. |
| 49 | $columns = \array_map(function (Filter $filter) { |
| 50 | return $filter->column(); |
| 51 | }, $filters); |
| 52 | $columns_to_disable = []; |
| 53 | if ($filter_logic === 'or' && (\in_array('submitted_form', $columns) || \in_array('clicked_link', $columns) || \in_array('page', $columns))) { |
| 54 | if (\in_array('views', $columns)) { |
| 55 | $columns_to_disable[] = 'views'; |
| 56 | } |
| 57 | if (\in_array('duration', $columns)) { |
| 58 | $columns_to_disable[] = 'duration'; |
| 59 | } |
| 60 | } |
| 61 | if (empty($columns_to_disable)) { |
| 62 | return $filters; |
| 63 | } |
| 64 | $modified_filters = \array_values(\array_filter($filters, function (Filter $filter) use($columns_to_disable) { |
| 65 | return !\in_array($filter->column(), $columns_to_disable); |
| 66 | })); |
| 67 | return $modified_filters; |
| 68 | } |
| 69 | public function groups() : Groups |
| 70 | { |
| 71 | $groups = []; |
| 72 | $groups[] = new Group('journey', \__('User Journeys', 'independent-analytics'), '', Journeys::class, Journey_Statistics::class); |
| 73 | return new Groups($groups); |
| 74 | } |
| 75 | protected function local_columns() : array |
| 76 | { |
| 77 | $columns = [new Column(['id' => 'created_at', 'name' => \__('Session Start', 'independent-analytics'), 'type' => 'date', 'visible' => \true, 'is_concrete_column' => \true, 'can_be_filtered' => \false]), new Column(['id' => 'cached_title', 'name' => \__('Landing Page Title', 'independent-analytics'), 'type' => 'string', 'visible' => \true, 'is_concrete_column' => \true, 'separate_filter_column' => 'initial_resources.cached_title']), new Column(['id' => 'landing_page_url', 'name' => \__('Landing Page URL', 'independent-analytics'), 'type' => 'string', 'visible' => \true, 'is_concrete_column' => \true, 'separate_filter_column' => 'initial_resources.cached_url']), new Column(['id' => 'page', 'name' => \__('Page Title', 'independent-analytics'), 'type' => 'string', 'visible' => \true, 'separate_filter_column' => 'resources.cached_title', 'is_concrete_column' => \true]), new Column(['id' => 'page_url', 'name' => \__('Page URL', 'independent-analytics'), 'type' => 'string', 'visible' => \true, 'is_concrete_column' => \true, 'separate_filter_column' => 'resources.cached_url']), new Column(['id' => 'referrer', 'name' => \__('Referrer', 'independent-analytics'), 'type' => 'string', 'visible' => \true, 'is_concrete_column' => \true, 'separate_database_column' => 'referrer']), new Column(['id' => 'views', 'name' => \__('Views', 'independent-analytics'), 'type' => 'int', 'visible' => \true, 'is_concrete_column' => \false]), new Column(['id' => 'duration', 'name' => \__('Session Duration', 'independent-analytics'), 'type' => 'int', 'visible' => \true, 'is_concrete_column' => \false]), new Column(['id' => 'country', 'name' => \__('Country', 'independent-analytics'), 'visible' => \true, 'type' => 'select', 'options' => new Options(new Countries()), 'separate_filter_column' => 'sessions.country_id', 'is_concrete_column' => \true]), new Column(['id' => 'device_type', 'name' => \__('Device Type', 'independent-analytics'), 'visible' => \true, 'type' => 'select', 'options' => new Options(new DeviceTypes()), 'separate_filter_column' => 'sessions.device_type_id', 'is_concrete_column' => \true]), new Column(['id' => 'device_browser', 'name' => \__('Browser', 'independent-analytics'), 'visible' => \true, 'type' => 'select', 'options' => new Options(new DeviceBrowsers()), 'separate_filter_column' => 'sessions.device_browser_id', 'is_concrete_column' => \true]), new Column(['id' => 'utm_source', 'name' => \__('Source', 'independent-analytics'), 'plugin_group' => 'campaigns', 'visible' => \true, 'type' => 'string', 'is_concrete_column' => \true]), new Column(['id' => 'utm_medium', 'name' => \__('Medium', 'independent-analytics'), 'plugin_group' => 'campaigns', 'visible' => \true, 'type' => 'string', 'is_concrete_column' => \true]), new Column(['id' => 'utm_campaign', 'name' => \__('Campaign', 'independent-analytics'), 'plugin_group' => 'campaigns', 'visible' => \true, 'type' => 'string', 'is_concrete_column' => \true]), new Column(['id' => 'utm_term', 'name' => \__('Term', 'independent-analytics'), 'plugin_group' => 'campaigns', 'type' => 'string', 'is_nullable' => \true, 'is_concrete_column' => \true]), new Column(['id' => 'utm_content', 'name' => \__('Content', 'independent-analytics'), 'plugin_group' => 'campaigns', 'type' => 'string', 'is_nullable' => \true, 'is_concrete_column' => \true]), new Column(['id' => 'submitted_form', 'name' => \__('Form Submission', 'independent-analytics'), 'plugin_group' => 'conversions', 'type' => 'select', 'options' => new Options(new FormConversions()), 'visible' => \true, 'is_concrete_column' => \true, 'separate_filter_column' => 'form_id']), new Column(['id' => 'clicked_link', 'name' => \__('Clicked Link', 'independent-analytics'), 'plugin_group' => 'conversions', 'type' => 'select', 'options' => new Options(new LinkPatternConversions()), 'visible' => \true, 'is_concrete_column' => \true, 'separate_filter_column' => 'clicks.link_rule_id']), new Column(['id' => 'wc_gross_sales', 'name' => \__('Gross Sales', 'independent-analytics'), 'plugin_group' => 'conversions', 'type' => 'int', 'visible' => \true, 'aggregatable' => \true])]; |
| 78 | return $columns; |
| 79 | } |
| 80 | } |
| 81 |