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

Controller.php « DBStats « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2cf1dcc0d7d960bbbb5f6cd07a8dfbdbe6688b9f (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?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 DBStats
 */
namespace Piwik\Plugins\DBStats;

use Piwik\MetricsFormatter;
use Piwik\Piwik;
use Piwik\View;
use Piwik\ViewDataTable\Factory;

/**
 * @package DBStats
 */
class Controller extends \Piwik\Plugin\ControllerAdmin
{
    /**
     * Returns the index for this plugin. Shows every other report defined by this plugin,
     * except the '...ByYear' reports. These can be loaded as related reports.
     *
     * Also, the 'getIndividual...Summary' reports are loaded by AJAX, as they can take
     * a significant amount of time to load on setups w/ lots of websites.
     */
    public function index()
    {
        Piwik::checkUserIsSuperUser();
        $view = new View('@DBStats/index');
        $this->setBasicVariablesView($view);

        $view->databaseUsageSummary = $this->getDatabaseUsageSummary(true);
        $view->trackerDataSummary = $this->getTrackerDataSummary(true);
        $view->metricDataSummary = $this->getMetricDataSummary(true);
        $view->reportDataSummary = $this->getReportDataSummary(true);
        $view->adminDataSummary = $this->getAdminDataSummary(true);

        list($siteCount, $userCount, $totalSpaceUsed) = API::getInstance()->getGeneralInformation();
        $view->siteCount = MetricsFormatter::getPrettyNumber($siteCount);
        $view->userCount = MetricsFormatter::getPrettyNumber($userCount);
        $view->totalSpaceUsed = MetricsFormatter::getPrettySizeFromBytes($totalSpaceUsed);

        echo $view->render();
    }

    /**
     * Shows a datatable that displays how much space the tracker tables, numeric
     * archive tables, report tables and other tables take up in the MySQL database.
     *
     * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise,
     *                    it is echoed.
     * @return string
     */
    public function getDatabaseUsageSummary($fetch = false)
    {
        Piwik::checkUserIsSuperUser();
        return $this->renderReport(__FUNCTION__, $fetch);
    }

    /**
     * Shows a datatable that displays the amount of space each individual log table
     * takes up in the MySQL database.
     *
     * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise,
     *                    it is echoed.
     * @return string|void
     */
    public function getTrackerDataSummary($fetch = false)
    {
        Piwik::checkUserIsSuperUser();
        return $this->renderReport(__FUNCTION__, $fetch);
    }

    /**
     * Shows a datatable that displays the amount of space each numeric archive table
     * takes up in the MySQL database.
     *
     * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise,
     *                    it is echoed.
     * @return string|void
     */
    public function getMetricDataSummary($fetch = false)
    {
        Piwik::checkUserIsSuperUser();
        return $this->renderReport(__FUNCTION__, $fetch);
    }

    /**
     * Shows a datatable that displays the amount of space each numeric archive table
     * takes up in the MySQL database, for each year of numeric data.
     *
     * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise,
     *                    it is echoed.
     * @return string|void
     */
    public function getMetricDataSummaryByYear($fetch = false)
    {
        Piwik::checkUserIsSuperUser();
        return $this->renderReport(__FUNCTION__, $fetch);
    }

    /**
     * Shows a datatable that displays the amount of space each blob archive table
     * takes up in the MySQL database.
     *
     * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise,
     *                    it is echoed.
     * @return string|void
     */
    public function getReportDataSummary($fetch = false)
    {
        Piwik::checkUserIsSuperUser();
        return $this->renderReport(__FUNCTION__, $fetch);
    }

    /**
     * Shows a datatable that displays the amount of space each blob archive table
     * takes up in the MySQL database, for each year of blob data.
     *
     * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise,
     *                    it is echoed.
     * @return string|void
     */
    public function getReportDataSummaryByYear($fetch = false)
    {
        Piwik::checkUserIsSuperUser();
        return $this->renderReport(__FUNCTION__, $fetch);
    }

    /**
     * Shows a datatable that displays how many occurances there are of each individual
     * report type stored in the MySQL database.
     *
     * Goal reports and reports of the format: .*_[0-9]+ are grouped together.
     *
     * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise,
     *                    it is echoed.
     * @return string|void
     */
    public function getIndividualReportsSummary($fetch = false)
    {
        Piwik::checkUserIsSuperUser();
        return $this->renderReport(__FUNCTION__, $fetch);
    }

    /**
     * Shows a datatable that displays how many occurances there are of each individual
     * metric type stored in the MySQL database.
     *
     * Goal metrics, metrics of the format .*_[0-9]+ and 'done...' metrics are grouped together.
     *
     * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise,
     *                    it is echoed.
     * @return string|void
     */
    public function getIndividualMetricsSummary($fetch = false)
    {
        Piwik::checkUserIsSuperUser();
        return $this->renderReport(__FUNCTION__, $fetch);
    }

    /**
     * Shows a datatable that displays the amount of space each 'admin' table takes
     * up in the MySQL database.
     *
     * An 'admin' table is a table that is not central to analytics functionality.
     * So any table that isn't an archive table or a log table is an 'admin' table.
     *
     * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise,
     *                    it is echoed.
     * @return string|void
     */
    public function getAdminDataSummary($fetch = false)
    {
        Piwik::checkUserIsSuperUser();
        return $this->renderReport(__FUNCTION__, $fetch);
    }
}