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

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2016-11-15 04:03:59 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2016-11-15 04:03:59 +0300
commit587cc39e0362719332d410b7a4d5ddcc68788eeb (patch)
treec982c369cdda542c3a4de08be11c893e5364838c /plugins/Marketplace/Environment.php
parent64314b26dbc6619d535002bdb79b9e55d1fc87db (diff)
Update Marketplace to work with new API (#10799)
* starting to port marketplace to piwik 3 * updating tests * fix translation key * fix various issues * use material select * fix plugin upload * deprecate license_homepage plugin metadata and link to a LICENSE[.md|.txt] file if found (#10756) * deprecate license_homepage plugin metadata, and link to a LICENSE[.md|.txt] file if found * Make license view HTML only without menu * fix tests and update * fix some links did not work * we need to show warnings even when plugin is installed, not only when activated. otherwise it is not clear why something is not downloadable * fix install was not working * improved responsiveness of marketplace * fix more tests * fix search was shown when only a few plugins are there * fix ui tests * fix some translations * fix tests and remove duplicated test
Diffstat (limited to 'plugins/Marketplace/Environment.php')
-rw-r--r--plugins/Marketplace/Environment.php104
1 files changed, 104 insertions, 0 deletions
diff --git a/plugins/Marketplace/Environment.php b/plugins/Marketplace/Environment.php
new file mode 100644
index 0000000000..0cfa124d9e
--- /dev/null
+++ b/plugins/Marketplace/Environment.php
@@ -0,0 +1,104 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Plugins\Marketplace;
+
+use Piwik\Common;
+use Piwik\Db;
+use Piwik\Plugin\ReleaseChannels;
+use Piwik\Plugins\CoreUpdater\ReleaseChannel;
+use Piwik\Version;
+
+class Environment
+{
+ /**
+ * @var ReleaseChannel
+ */
+ private $releaseChannel;
+
+ private $usersCache = null;
+ private $websitesCache = null;
+ private $mySqlCache = null;
+ private $piwikVersion = null;
+
+ public function __construct(ReleaseChannels $releaseChannels)
+ {
+ $this->releaseChannel = $releaseChannels->getActiveReleaseChannel();
+ }
+
+ public function setPiwikVersion($piwikVersion)
+ {
+ $this->piwikVersion = $piwikVersion;
+ }
+
+ public function getNumUsers()
+ {
+ if (!isset($this->usersCache)) {
+ $this->usersCache = (int) Db::get()->fetchOne('SELECT count(login) FROM ' . Common::prefixTable('user') . ' WHERE login <> "anonymous" ');
+ }
+
+ return $this->usersCache;
+ }
+
+ public function getNumWebsites()
+ {
+ if (!isset($this->websitesCache)) {
+ $this->websitesCache = (int) Db::get()->fetchOne('SELECT count(idsite) FROM ' . Common::prefixTable('site'));
+ }
+
+ return $this->websitesCache;
+ }
+
+ public function getPhpVersion()
+ {
+ return PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
+ }
+
+ public function getPiwikVersion()
+ {
+ if (!empty($this->piwikVersion)) {
+ return $this->piwikVersion;
+ }
+
+ return Version::VERSION;
+ }
+
+ public function doesPreferStable()
+ {
+ if (!empty($this->releaseChannel)) {
+ return $this->releaseChannel->doesPreferStable();
+ }
+
+ return true;
+ }
+
+ public function getReleaseChannel()
+ {
+ if (!empty($this->releaseChannel)) {
+ return $this->releaseChannel->getId();
+ }
+ }
+
+ public function getMySQLVersion()
+ {
+ if (isset($this->mySqlCache)) {
+ return $this->mySqlCache;
+ }
+
+ $this->mySqlCache = '';
+
+ $db = Db::get();
+ if (method_exists($db, 'getServerVersion')) {
+ $this->mySqlCache = $db->getServerVersion();
+ }
+
+ return $this->mySqlCache;
+ }
+
+
+}