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

Live.php « Live « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 543efd8fb86c7d2356c43e30beaf26a8a44149ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 * @category Piwik_Plugins
 * @package Live
 */
namespace Piwik\Plugins\Live;

use Piwik\Piwik;
use Piwik\Common;
use Piwik\WidgetsList;

/**
 *
 * @package Live
 */
class Live extends \Piwik\Plugin
{
    /**
     * This event is called in the Live.getVisitorProfile API method. Plugins can use this event
     * to discover and add extra data to visitor profiles.
     * 
     * For example, if an email address is found in a custom variable, a plugin could load the
     * gravatar for the email and add it to the visitor profile so it will display in the 
     * visitor profile popup.
     * 
     * The following visitor profile elements can be set to augment the visitor profile popup:
     * - visitorAvatar: A URL to an image to display in the top left corner of the popup.
     * - visitorDescription: Text to be used as the tooltip of the avatar image.
     * 
     * Callback Signature: function (array &$result);
     */
    const GET_EXTRA_VISITOR_DETAILS_EVENT = 'Live.getExtraVisitorDetails';

    /**
     * @see Piwik_Plugin::getListHooksRegistered
     */
    public function getListHooksRegistered()
    {
        return array(
            'AssetManager.getJavaScriptFiles'          => 'getJsFiles',
            'AssetManager.getStylesheetFiles'          => 'getStylesheetFiles',
            'WidgetsList.addWidget'                    => 'addWidget',
            'Menu.addMenuEntry'                        => 'addMenu',
            'ViewDataTable.getReportDisplayProperties' => 'getReportDisplayProperties',
            'Translate.getClientSideTranslationKeys'   => 'getClientSideTranslationKeys',
        );
    }

    public function getStylesheetFiles(&$stylesheets)
    {
        $stylesheets[] = "plugins/Live/stylesheets/live.less";
        $stylesheets[] = "plugins/Live/stylesheets/visitor_profile.less";
    }

    public function getJsFiles(&$jsFiles)
    {
        $jsFiles[] = "plugins/Live/javascripts/live.js";
        $jsFiles[] = "plugins/Live/javascripts/visitorProfile.js";
        $jsFiles[] = "plugins/Live/javascripts/visitorLog.js";
    }

    public function addMenu()
    {
        Piwik_AddMenu('General_Visitors', 'Live_VisitorLog', array('module' => 'Live', 'action' => 'indexVisitorLog'), true, $order = 5);
    }

    public function addWidget()
    {
        WidgetsList::add('Live!', 'Live_VisitorsInRealTime', 'Live', 'widget');
        WidgetsList::add('Live!', 'Live_VisitorLog', 'Live', 'getVisitorLog');
        WidgetsList::add('Live!', 'Live_RealTimeVisitorCount', 'Live', 'getSimpleLastVisitCount');
        WidgetsList::add('Live!', 'Live_VisitorProfile', 'Live', 'getVisitorProfilePopup');
    }

    public function getClientSideTranslationKeys(&$translationKeys)
    {
        $translationKeys[] = "Live_VisitorProfile";
        $translationKeys[] = "Live_NoMoreVisits";
        $translationKeys[] = "Live_ShowMap";
        $translationKeys[] = "Live_HideMap";
        $translationKeys[] = "Live_PageRefreshed";
    }

    public function getReportDisplayProperties(&$properties)
    {
        $properties['Live.getLastVisitsDetails'] = $this->getDisplayPropertiesForGetLastVisitsDetails();
    }

    private function getDisplayPropertiesForGetLastVisitsDetails()
    {
        return array(
            'default_view_type'           => 'Piwik\\Plugins\\Live\\VisitorLog',
            'disable_generic_filters'     => true,
            'enable_sort'                 => false,
            'filter_sort_column'          => 'idVisit',
            'filter_sort_order'           => 'asc',
            'show_search'                 => false,
            'filter_limit'                => 20,
            'show_offset_information'     => false,
            'show_exclude_low_population' => false,
            'show_all_views_icons'        => false,
            'show_table_all_columns'      => false,
            'show_export_as_rss_feed'     => false,
            'documentation'               => Piwik_Translate('Live_VisitorLogDocumentation', array('<br />', '<br />')),
            'custom_parameters'           => array(
                // set a very high row count so that the next link in the footer of the data table is always shown
                'totalRows'         => 10000000,

                'filterEcommerce'   => Common::getRequestVar('filterEcommerce', 0, 'int'),
                'pageUrlNotDefined' => Piwik_Translate('General_NotDefined', Piwik_Translate('Actions_ColumnPageURL'))
            ),
            'footer_icons'                => array(
                array(
                    'class' => 'tableAllColumnsSwitch',
                    'buttons' => array(
                        array(
                            'id' => 'Piwik\\Plugins\\Live\\VisitorLog',
                            'title' => Piwik_Translate('Live_LinkVisitorLog'),
                            'icon' => 'plugins/Zeitgeist/images/table.png'
                        )
                    )
                )
            ),
            'visualization_properties'    => array(
                'table' => array(
                    'disable_row_actions' => true,
                )
            )
        );
    }
}