PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.0.6
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.0.6
5.13.0 5.12.1 5.12.0 5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / core / Settings / Storage / Backend / SitesTable.php
matomo / app / core / Settings / Storage / Backend Last commit date
BackendInterface.php 2 years ago BaseSettingsTable.php 2 years ago Cache.php 2 years ago Config.php 2 years ago MeasurableSettingsTable.php 2 years ago NullBackend.php 2 years ago PluginSettingsTable.php 2 years ago SitesTable.php 2 years ago
SitesTable.php
92 lines
1 <?php
2
3 /**
4 * Matomo - free/libre analytics platform
5 *
6 * @link https://matomo.org
7 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
8 *
9 */
10 namespace Piwik\Settings\Storage\Backend;
11
12 use Piwik\Plugins\SitesManager\Model;
13 use Piwik\Site;
14 use Exception;
15 /**
16 * Backend for an existing site. Stores all settings in the "site" database table.
17 */
18 class SitesTable implements \Piwik\Settings\Storage\Backend\BackendInterface
19 {
20 /**
21 * @var int
22 */
23 private $idSite;
24 private $commaSeparatedArrayFields = array('sitesearch_keyword_parameters', 'sitesearch_category_parameters', 'excluded_user_agents', 'excluded_parameters', 'excluded_ips', 'excluded_referrers');
25 // these fields are standard fields of a site and cannot be adjusted via a setting
26 private $allowedNames = array('ecommerce', 'sitesearch', 'sitesearch_keyword_parameters', 'sitesearch_category_parameters', 'exclude_unknown_urls', 'excluded_ips', 'excluded_parameters', 'excluded_referrers', 'excluded_user_agents', 'keep_url_fragment', 'urls');
27 public function __construct($idSite)
28 {
29 if (empty($idSite)) {
30 throw new Exception('No idSite given for Measurable backend');
31 }
32 $this->idSite = (int) $idSite;
33 }
34 /**
35 * @inheritdoc
36 */
37 public function getStorageId()
38 {
39 return 'SitesTable_' . $this->idSite;
40 }
41 /**
42 * Saves (persists) the current setting values in the database.
43 */
44 public function save($values)
45 {
46 $model = $this->getModel();
47 foreach ($values as $key => $value) {
48 if (!in_array($key, $this->allowedNames)) {
49 unset($values[$key]);
50 continue;
51 }
52 if (is_array($value) && in_array($key, $this->commaSeparatedArrayFields)) {
53 $values[$key] = implode(',', $value);
54 } elseif (is_bool($value)) {
55 $values[$key] = (int) $value;
56 }
57 }
58 if (!empty($values['urls'])) {
59 $urls = array_unique($values['urls']);
60 $values['main_url'] = array_shift($urls);
61 $model->deleteSiteAliasUrls($this->idSite);
62 foreach ($urls as $url) {
63 $model->insertSiteUrl($this->idSite, $url);
64 }
65 }
66 unset($values['urls']);
67 $model->updateSite($values, $this->idSite);
68 Site::clearCacheForSite($this->idSite);
69 }
70 public function load()
71 {
72 if (!empty($this->idSite)) {
73 $site = Site::getSite($this->idSite);
74 $urls = $this->getModel();
75 $site['urls'] = $urls->getSiteUrlsFromId($this->idSite);
76 foreach ($this->commaSeparatedArrayFields as $field) {
77 if (!empty($site[$field]) && is_string($site[$field])) {
78 $site[$field] = explode(',', $site[$field]);
79 }
80 }
81 return $site;
82 }
83 }
84 private function getModel()
85 {
86 return new Model();
87 }
88 public function delete()
89 {
90 }
91 }
92