diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2016-11-15 04:03:59 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-11-15 04:03:59 +0300 |
commit | 587cc39e0362719332d410b7a4d5ddcc68788eeb (patch) | |
tree | c982c369cdda542c3a4de08be11c893e5364838c /core/Plugin/MetadataLoader.php | |
parent | 64314b26dbc6619d535002bdb79b9e55d1fc87db (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 'core/Plugin/MetadataLoader.php')
-rw-r--r-- | core/Plugin/MetadataLoader.php | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/core/Plugin/MetadataLoader.php b/core/Plugin/MetadataLoader.php index 5a6b2617e6..bde849ff7e 100644 --- a/core/Plugin/MetadataLoader.php +++ b/core/Plugin/MetadataLoader.php @@ -57,6 +57,12 @@ class MetadataLoader unset($plugin['description']); } + // look for a license file + $licenseFile = $this->getPathToLicenseFile(); + if(!empty($licenseFile)) { + $plugin['license_file'] = $licenseFile; + } + return array_merge( $defaults, $plugin @@ -78,7 +84,6 @@ class MetadataLoader 'homepage' => 'http://piwik.org/', 'authors' => array(array('name' => 'Piwik', 'homepage' => 'http://piwik.org/')), 'license' => 'GPL v3+', - 'license_homepage' => 'http://www.gnu.org/licenses/gpl.html', 'version' => Version::VERSION, 'theme' => false, 'require' => array() @@ -87,7 +92,7 @@ class MetadataLoader private function loadPluginInfoJson() { - $path = \Piwik\Plugin\Manager::getPluginsDirectory() . $this->pluginName . '/' . self::PLUGIN_JSON_FILENAME; + $path = $this->getPathToPluginFolder() . '/' . self::PLUGIN_JSON_FILENAME; return $this->loadJsonMetadata($path); } @@ -111,4 +116,32 @@ class MetadataLoader return $info; } + + /** + * @return string + */ + private function getPathToPluginFolder() + { + return \Piwik\Plugin\Manager::getPluginsDirectory() . $this->pluginName; + } + + /** + * @return null|string + */ + public function getPathToLicenseFile() + { + $prefixPath = $this->getPathToPluginFolder() . '/'; + $licenseFiles = array( + 'LICENSE', + 'LICENSE.md', + 'LICENSE.txt' + ); + foreach ($licenseFiles as $licenseFile) { + $pathToLicense = $prefixPath . $licenseFile; + if (is_file($pathToLicense) && is_readable($pathToLicense)) { + return $pathToLicense; + } + } + return null; + } } |