This repository has been archived by the owner on Dec 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Counter.php
88 lines (79 loc) · 2.33 KB
/
Counter.php
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
<?php
/**
* @package Piwik.Counter
* @copyright Copyright (C) 2010 Libra.ms. All rights reserved.
* @license GNU General Public License version 3 or later
* @url http://xn--80aeqbhthr9b.com/en/others/piwik/10-piwik-graphical-counter.html
* @url http://киноархив.com/ru/разное/piwik/9-piwik-графический-счетчик.html
*/
namespace Piwik\Plugins\Counter;
use Piwik\Common;
use Piwik\Db;
use Piwik\Plugin;
/**
* Plugin class.
*/
class Counter extends Plugin
{
/**
* Associate callbacks with events.
*/
public function registerEvents()
{
return array(
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
);
}
public function getStylesheetFiles(&$stylesheets)
{
$stylesheets[] = 'plugins/Counter/assets/css/style.css';
}
public function getJsFiles(&$jsFiles)
{
$jsFiles[] = 'plugins/Counter/assets/js/ui.aurora.min.js';
}
/**
* Executed every time the plugin is enabled.
*
* @throws \Exception
*/
public function activate()
{
$this->install();
}
/**
* Installs the plugin.
*
* @throws \Exception
*/
public function install()
{
try {
$query = "CREATE TABLE IF NOT EXISTS " . Common::prefixTable('counter_sites') . "( "
. " id INT(11) NOT NULL AUTO_INCREMENT,"
. " idsite INT(11) NOT NULL,"
. " title VARCHAR(64) NOT NULL DEFAULT '',"
. " params TEXT NOT NULL,"
. " visits INT(11) NOT NULL DEFAULT '0',"
. " views INT(11) NOT NULL DEFAULT '0',"
. " published TINYINT(1) NOT NULL DEFAULT '0',"
. " PRIMARY KEY (id),"
. " KEY idx_idsite (idsite),"
. " KEY idx_state (published)"
. " ) ENGINE=MYISAM DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci";
Db::exec($query);
} catch (\Exception $e) {
if (!Db::get()->isErrNo($e, '1050')) {
throw $e;
}
}
}
/**
* Uninstalls the plugins.
*/
public function uninstall()
{
Db::dropTables(Common::prefixTable('counter_sites'));
}
}